Introduction: DIY Alarm Clock
After designing the "Clock Set Date Time" and hearing the suggestion of "maewert" I thought it would be a good idea and also useful, add a "wake-up alarm."
A small change to the code and adding a few components: Here's "the Alarm Clock"
Step 1: Material
- Arduino or Arduino standalone
- RTC DS1307 or DS3231
- 20x4 LCD I2C
- 4 buttons
- Diodo led
- 1 Resistor 220 ohm
- Piezzo Buzzer (from Arduino starter kit)
- Wires
Step 2: Schematics
Compared to the "Clock Set Date Time" I added a Piezzo buzzer, an LED diode, a resistor of 220 ohm,one button, and as mentioned before, I have listened the suggestion to "maewert" and I removed the resistances to "pull down".
Attachments
Step 3: Arduino Code
Link libraries:
- Wire.h :by Arduino IDE
- RTClib.h
- LiquidCrystal_I2C.h
- Code: https://create.arduino.cc/editor/Tittiamo/66248b63-6d32-4ca9-929c-517de0c676c3/preview
To remove the "pull down" resistances I had to make a change to the code.
Use the pullup resistors of arduino, and reverse the code logic conditions.
pinMode(P1,INPUT_PULLUP);
pinMode(P2,INPUT_PULLUP);
pinMode(P3,INPUT_PULLUP);
pinMode(P4,INPUT_PULLUP);
if(digitalRead(P1)==LOW)
{
menu=menu+1;
Step 4: The Alarm Code
The activation and deactivation of the alarm clock is controlled by the "P4" button, line 444 "void Alarm()".
To enter the alarm settings, you must use the "P3" "P2" buttons together, line 81 "if((digitalRead(P2)== LOW)&&(digitalRead(P3)== LOW))".
When the alarm is not set, the bottom of the display will show "Alarm Off" when the alarm is active, it shows the time that has been set.
At the scheduled time, the display flashes, the LED lights up, and the buzzer sounds two tones.
To turn off the alarm, you have to act on the P4 button, or, after a minute, it turns off alone
Step 5: Work in Progress
I'm working to put it all in my "Weather Clock"