This project works as a digital clock wherein a user can also set alarm. Additionally, it also works as a digital thermometer to specify the ambient temperature. Both, the clock and temperature are displayed on a 16x2 LCD screen using the 8051 microcontroller (AT89C51). AT89C51 is an eight bit controller which belongs to the 8051 family of microcontrolers.
Celsius scale thermometer displays the ambient temperature through a LCD display. It consists of two sections. One is that which senses the temperature. This is a temperature sensor LM 35. The other section converts the temperature value into a suitable number in Celsius scale which is done by the ADC0804. A digital thermometer can be easily made by interfacing a temperature sensor to the microcontroller AT89C51. The temperature sensor used in the project isLM35. The LM 35 IC generates a 10mV variation to its output voltage for every degree Celsius change in temperature. The Output of the temperature sensor is analog in nature so we need an analog to digital convertor for converting the analog input to its equivalent binary output.ADC 0804 is an analog to digital convertor IC used in the project. 0804 is a single channel convertor which converts the analog input up to a range of 5V to an equivalent 8-bit binary output.
This project incorporates the functionality of a digital clock and a digital thermometer. The digital clock works in 12 hour mode and is configured by programming the 8051 microcontroller (AT89C51). The program uses a delay function for producing a delay of 1 second. The clock and alarm times can be set through a set of external tactile switches.
Project Source Code
###
// Program to make a digital clock with integrated Alarm and digital thermometer #include<reg51.h> #define port P1 #define adc_input P0 #define cont_port P3 #define dataport P2 #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; sbit wr= P3^2; sbit rd= P3^3; sbit intr= P3^4; 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; int test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,0}; void delay(unsigned int msec) // Time dealy 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]!='