An alarm clock is a clock that indicates a pre-set time by producing sound at that time. This functionality of digital clock is used to awaken people or remind them of something. This circuit is an extension to the digital clock with time setting option. Here an extra switch is provided to set the alarm. While the alarm is set, the clock time does not stop and runs in the background.The circuit is build around 8051 microcontroller (AT89C51) and uses LCD to display time.
This is an improved version of digital clock with LCD display. It has an extra feature to set the alarm in the starting. On reset, the LCD prompts the user to set alarm. Only the hour and minute components can be set by pressing the corresponding switches, repeatedly. These switches are made active low and so they provide ground to the corresponding input pins of the microcontroller AT89C51. The AM/PM mode is set by toggling the switch between ground and Vcc. Ground would set the clock in AM mode while Vcc would set it in PM mode.
After the alarm is set, the alarm pin is connected to Vcc (high) through switch. The procedure of setting time remains the same as with a simple digital clock. When the clock time becomes equal to the alarm time, a message ‘Alarm’ is displayed on LCD and alarm pin of microcontroller goes high for some duration. This pin can be connected to a speaker or buzzer to sound the alarm at the pre-set time.
Project Source Code
###
//Program to make a digital clock with time and alaram setting function #include<reg51.h> #define port P1 #define cont_port P3 #define dataport P2 //Data port for LCD #define m_sec 10 sbit rs = cont_port^0; sbit rw = cont_port^1; sbit en = cont_port^6; sbit dig_hr1=port^0; sbit dig_min1=port^1; sbit start=port^2; sbit am_pm=port^3; sbit alarm_set=port^4; sbit alarm=port^7; int hr ,hr1=0,alarm_hr=0; int min,min1=0,alarm_min=0; int sec,sec1=0,dig_am_pm=0,alarm_am_pm=0; void delay(unsigned int msec) // Time delay function { int i,j ; for(i=0;i<msec;i++) for(j=0;j<1275;j++); } void lcd_cmd(unsigned char item) //Function to send command to LCD { dataport = item; rs= 0; rw=0; en=1; delay(1); en=0; return; } void lcd_data(unsigned char item) // Function to send data to LCD { dataport = item; rs= 1; rw=0; en=1; delay(1); en=0; return; } void lcd_data_string(unsigned char *str) // Function to send string to LCD { int i=0; while(str[i]!='