In this project, I have made myself a simple digital alarm clock which I could make use of what I learnt before. Making this digital alarm clock involves interfacing with LCD and DS1307 Real Time Clock. If you not familiar with them, I would suggest you to read Liquid Crystal Display HD44780 and DS 1307 Real Time Clock

Here is a video preview to the digital alarm clock.

I won’t go into detail for LCD but there is something extra to cover on DS1307 Real Time Clock. From my previous post, we know that DS1307 can gives us informations such as second, minute, hour, day of week, day, month and year. All these information can be obtained from DS1307 through I2C communication.

Capture
Registers of DS1307 RTC

Usually a clock allows the user to set his own time and date. So you need to read and write to the respective registers to modify the value. Therefore, to use I2C of Arduino, you can use it with Wire.h library. More information on Wire.h library can be obtained from Arduino website.

l293d 3

Besides that, in my digital alarm clock, the user can set alarm function. When the time set reached, the buzzer will beeps, just like a normal alarm clock. So the user need to press the designed button to reset the alarm.

I have also tried to make some custom characters for the LCD as an icon for alarm on.

l293d 4

l293d 2

An example code of creating a custom character on LCD with Arduino.

#include <LiquidCrystal.h>

LiquidCrystal lcd(5,6,7,8,9,10);

byte icon1[8]={B00000,B00100,B01110,B01110,B01110,B11111,B00100,B00000};
void setup()
{
 lcd.begin(16,2);
 lcd.createChar(0,icon1);

}

void loop()
{
 lcd.write(byte(0))
}

Explanation of code:

lcd.createChar(num,data)

– This function allows you to create 5×8 pixels character. So the number is the number of character to create, in between 0 to 7. While the data is the character pixel data. So you can define the character in an array.

lcd.write(data)

– This allows you to write character on LCD.

Now you can try to create your own custom character on LCD.

This is a simple digital alarm clock that I have made, but there is still a lot of room of improvement. So I’m going to upgrade this digital clock soon.

Advertisements