OVERVIEW
If you ever flown an RC Plane or Drone, you know that it’s easy to lose control and no matter how good you are, crashing is something that will eventually happen.
But what do you do if the site of the crash is located inside a corn field or in a forest?
You might be walking right beside it while searching, and not even see it!
Here a little project that will sound an Alarm after a set time and will help you locate your lost RC vehicle.
In this tutorial we will “not” use some sort of “crash detector” or GPS, instead we will take into account that most RC planes or drones have a maximum flight time due to the battery they use.
Most of them can fly for around 20 minutes before the battery runs out (some more,some less…) so in theory, if we set the timer above that duration (30 minutes for example), then if that timer elapse and the alarm is sounded, we can assume that our RC plane or drone has not returned to us and is crashed somewhere.
So at least the sound of the Alarm will guide you in the right direction so you can retrieve your lost RC plane/drone.
We will be using the DigiSpark, since it’s very small and we don’t need a lot of pins.
Everything can be powered using a regular 9V battery.
PARTS USED
4 Digits 7 Segment Display
DigiSpark
Passive Buzzer Module
These are Amazon affiliate links...
They don't cost you anything and it helps me keep the lights on
if you buy something on Amazon. Thank you!
CONNECTIONS
AHere are the connection needed for this tutorial:
The GND and 5V (out) of the DigiSpark is connected to the breadboard power rails.
The GND of the Buzzer is connected to the GND rail of the breadboard.
The positive (+) of the buzzer is connected to pin 2 of the Digispark.
The VCC and GND of the 4 Digit Display are connected to the breadbard power rails.
The CLK and DIO pins of the 4 Digit Display are connected to pin 0 and 1 of the DigiSpark.
The positive (+) of the 9V battery is connected to the VIN pin of the DigiSpark.
The GND (-) of the 9V battery is connected to the GND rail of the breadboard.
THE CODE
We are using a 4 bit 7 segment display to create a countdown timer, of course this is optional if you just want to sound the Alarm and not have a display.
But using the display confirms that it is working and we can visualize the entered value of the timer.
We are using the “DigitalTube” library created by Frankie Chu (https://github.com/reeedstudio/libraries/tree/master/DigitalTube)
to control the 7 segment display.
Don’t forget to watch our Tutorial video for more information.
#include "TM1637.h" // Library for 7 segment Display
//{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
//0~9,A,b,C,d,E,F // Available for display
// DigitalTube Library
// created by Frankie Chu: https://github.com/reeedstudio/libraries/tree/master/DigitalTube
// Pins for display
#define CLK 0
#define DIO 1
#define Buzzer 2 // Pin 2 connected to buzzer + positive
int timer_val=1; // Countdown value in minutes
int timer_seconds=30; // used to display seconds
// Variables used to store individual numbers
int firstnum=0;
int secondnum=0;
int thirdnum=0;
int fournum=0;
TM1637 tm1637(CLK,DIO); // Create instance of 7 segment Display
void setup(){
pinMode(Buzzer, OUTPUT);
digitalWrite(Buzzer, LOW);
tm1637.init(); // Reset Display
tm1637.set(BRIGHT_TYPICAL); // BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
tm1637.point(POINT_ON); // Put center "colons" ON
delay(1500); // Delay to let system boot
}
void loop() {
// Check if timer is elapsed
while (timer_val == 0 && timer_seconds == 0) {
tm1637.clearDisplay(); // Clear display
tm1637.display(0,0);
tm1637.display(1,0);
tm1637.display(2,0);
tm1637.display(3,0);
digitalWrite(Buzzer, HIGH);
delay(500);
tm1637.clearDisplay();
digitalWrite(Buzzer, LOW);
delay(250);
}
// Breakdown minutes and seconds in individual numbers
if (timer_val > 9) {
firstnum = timer_val/10%10;
secondnum = timer_val%10;
}
else {
secondnum = timer_val;
}
if (timer_seconds > 9) {
thirdnum = timer_seconds/10%10;
fournum = timer_seconds%10;
}
else {
thirdnum = 0;
fournum = timer_seconds;
}
// Display timer on 4 bits 7 segments display
tm1637.clearDisplay(); // Clear display
if (timer_val > 9) {
tm1637.display(0,firstnum);
}
if (timer_val > 0) {
tm1637.display(1,secondnum);
}
if (timer_seconds > 9 || timer_val > 0) {
tm1637.display(2,thirdnum);
}
tm1637.display(3,fournum);
// Decrease seconds
timer_seconds=timer_seconds-1;
delay(1000); // Delay of 1 second
// Decrease timer
if (timer_seconds == -1) {
timer_val=timer_val-1;
timer_seconds=59;
}
}
TUTORIAL VIDEO
DOWNLOAD
Copy the above Sketch code in your Arduino IDE software to program your Arduino.
Used Libraries:
Download The DigitalTube Library
created by Frankie Chu here: https://github.com/reeedstudio/libraries/tree/master/DigitalTube
Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder, and make sure to restart the Arduino IDE (Close and Reopen) software so it detect this newly installed library.
Comments