Arduino Alarm Clock

by calvejo in Circuits > Arduino

603 Views, 1 Favorites, 0 Comments

Arduino Alarm Clock

8E896841-8AB0-4467-8216-320B929FC0B8.jpeg
This is an Alarm Clock powered by Arduino. It keeps track track of time down to the seconds. Once the alarm time is reached, the alarm goes off for one minute, then shuts off automatically.

Supplies

For this project you will need a couple things,
Arduino Uno
16 pin LCD screen
Buzzer
Potentiometer
DS3231 RTC
Breadboard
Jumper Wires

Hardware

34384BF6-72AE-401E-B1B2-E759F684859B.png
First you need to wire everything together. Here is the circuit diagram and A picture of my project.

Code

Pasted below is the code to the project, upload this to the arduino and un comment the time you need to set.

#include

#include

#include

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

DS3231 rtc(SDA, SCL);

Time t;

#define buz 11

int Hor;

int Min;

int Sec;




void setup()

{

Wire.begin();

rtc.begin();

Serial.begin(9600);

pinMode(buz, OUTPUT);

lcd.begin(16,2);

lcd.setCursor(0,0);

lcd.print("DIYHacking.com");

lcd.setCursor(0,1);

lcd.print("Arduino Alarm ");

// The following lines can be uncommented to set the date and time

//rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY

//rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)

//rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014

delay(2000);

}




void loop()

{

t = rtc.getTime();

Hor = t.hour;

Min = t.min;

Sec = t.sec;

lcd.setCursor(0,0);

lcd.print("Time: ");

lcd.print(rtc.getTimeStr());

lcd.setCursor(0,1);

lcd.print("Date: ");

lcd.print(rtc.getDateStr());




if( Hor == 11 && (Min == 32 || Min == 33)) //Comparing the current time with the Alarm time

{

Buzzer();

Buzzer();

lcd.clear();

lcd.print("Alarm ON");

lcd.setCursor(0,1);

lcd.print("Alarming");

Buzzer();

Buzzer();

}

delay(1000);

}




void Buzzer()

{

digitalWrite(buz,HIGH);

delay(500);

digitalWrite(buz, LOW);

delay(500);

}

Finished Project

Place the hardware inside a container with the LCD visible. Now the project is finished. The small piezo buzzers won’t work for this project. The voltage this circuit draws is too high and the buzzer won’t receive enough power. Here is the one I used - Buzzer.

Problems I Ran Into

While working on this project there were several problems. The code I was using wasn't perfect and I had to change some of it, but the one posted here is my edited version and should work fine. Also, if the buzzer isn't loud enough, there is probably a voltage drop within the circuit. The arduino can handle up to 20 volts worth of input, but most power supplies are 3.2-5v. This isn't enough for the circuit and won't work with the small piezo buzzers. This problem can be fixed with a larger voltage power supply or just a louder buzzer, which is what I used.