EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / LCD based digital alarm clock with digital thermometer using 8051 microcontroller (AT89C51)

LCD based digital alarm clock with digital thermometer using 8051 microcontroller (AT89C51)

|

Microcontroller › 8051 › LCD based digital alarm clock with digital thermometer using 8051 microcontroller (AT89C51)

  • This topic has 6 replies, 3 voices, and was last updated 8 years, 5 months ago by sharon.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • April 2, 2017 at 11:16 pm #4635
    indrajeet Tmabe
    Participant

    my query is regarding

    LCD based digital alarm clock with digital thermometer using 8051 microcontroller (AT89C51)

    The code that is provided for the project is incorrect as the clock is not running and lcd is not showing temperature tooo

    please provide us a genune working code

    April 3, 2017 at 4:12 am #14549
    Hari Prasaath K
    Participant

    Hi,

    The code provided in site are practically worked and tested.

    Please provide the details at which part exactly you face the problem.

    Test your project module by module. check with your hardware connections also whether it matches according to code given side.

    April 3, 2017 at 9:27 am #14550
    indrajeet Tmabe
    Participant

    hello,

    I have constructed your circuit in proteus 8 and also constructed on the bread board output on both are same
    1st it says set time we are able to set time
    then it displays the time that we have set and seconds digits are stuck to 00 they dont procedue
    cant set alarm it also do not display the temperature
    provide me with ur direct contact details

    April 3, 2017 at 10:09 am #14552
    Hari Prasaath K
    Participant

    Send the clear screenshot of simulation circuit design that you done with your proteus and attach the code also.

    April 3, 2017 at 10:40 am #14553
    indrajeet Tmabe
    Participant

    then after we set time it comes out to the bellow diagram

     

    OUR CODE IS

    // 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!='')
     
    {
     
      lcd_data(str);
     
      i++;
     
      delay(1);
     
    }
     
    return;
     
    }
     
     
     
     
    lcd_data_int(int time_val)  // Function to send number to LCD
     
    {
     
    int int_amt;
     
    int_amt=time_val/10;
     
    lcd_data(int_amt+48);
     
    int_amt=time_val%10; 
     
    lcd_data(int_amt+48);
     
    }
     
     
     
     
    void lcd(unsigned char str1[10])
     
    {
     
    lcd_cmd(0x38); 
     
    lcd_cmd(0x0e); 
     
    delay(1);
     
    lcd_data_string(str1);
     
    }
     
     
     
     
    void shape()  // Function to create the shape of degree
     
    {
     
    lcd_cmd(64);
     
    lcd_data(2);
     
    lcd_data(5);
     
    lcd_data(2);
     
    lcd_data(0);
     
    lcd_data(0);
     
    lcd_data(0);
     
    lcd_data(0);
     
    lcd_data(0);
     
    }
     
     
     
     
    void convert()  // Function to convert the data of ADC
     
    {
     
    int s;
     
    s=test_final/100;
     
    test_final=test_final%100;
     
    lcd_cmd(0xc9);
     
    if(s!=0)
     
    lcd_data(s+48);
     
    else
     
    lcd_cmd(0x06);
     
    s=test_final/10;
     
    test_final=test_final%10;
     
    lcd_data(s+48);
     
    lcd_data(test_final+48);
     
    lcd_data(0);
     
    lcd_data('C');
     
    lcd_data(' ');
     
    delay(2);
     
    }
     
     
     
     
    void set_hr1()  // Function to set set hours digit of clock
     
    {
     
    hr1++;
     
    if(hr1>11)
     
    hr1=0;
     
    lcd_cmd(0xc3);
     
    lcd_data_int(hr1);
     
    lcd_data(':');
     
    }
     
     
     
     
    void set_min1()  // Function to set set minutes digit of clock
     
    {
     
    min1++;
     
    if(min1>59)
     
    min1=0;
     
    lcd_cmd(0xc6);
     
    lcd_data_int(min1);
     
    }
     
     
     
     
    void set_alarm_hr1() // Function to set set hours digit of alarm
     
    {
     
    alarm_hr++;
     
    if(alarm_hr>11)
     
    alarm_hr=0;
     
    lcd_cmd(0xc3);
     
    lcd_data_int(alarm_hr);
     
    lcd_data(':');
     
    }
     
     
     
     
    void set_alarm_min1() // Function to set set minutes digit of clock
     
    {
     
    alarm_min++;
     
    if(alarm_min>59)
     
    alarm_min=0;
     
    lcd_cmd(0xc6);
     
    lcd_data_int(alarm_min);
     
    }
     
     
     
     
    void alarm_check()  // Function to check alarm
     
    {
     
    if(hr==alarm_hr)
     
    {
     
      if(min==alarm_min)
     
      {
     
       if(dig_am_pm==alarm_am_pm)
     
       {
     
        alarm=1;
     
        lcd_cmd(0x8b);
     
        lcd("ALARM");
     
       }
     
      }
     
    } 
     
    }
     
     
     
     
    void temp() // Function to calculate temperature
     
    {
     
    int i;
     
    for(i=0;i<10;i++)
     
    {
     
      delay(1);
     
      rd=1;
     
      wr=0;
     
      delay(1);
     
      wr=1;
     
      while(intr==1);
     
      rd=0;
     
      lcd_cmd(0x88);
     
      test_intermediate1=adc_input/10;
     
      delay(1);
     
      intr=1;
     
    }
     
    for(i=0;i<10;i++)
     
    test_intermediate2[0]=test_intermediate1+test_intermediate2[0];
     
     
     
     
    for(i=0;i<10;i++)
     
    {
     
      delay(1);
     
      rd=1;
     
      wr=0;
     
      delay(1);
     
      wr=1;
     
      while(intr==1);
     
      rd=0;
     
      lcd_cmd(0x88);
     
      test_intermediate1=adc_input/10;
     
      delay(1);
     
      intr=1;
     
    }
     
    for(i=0;i<10;i++)
     
    test_intermediate2[1]=test_intermediate1+test_intermediate2[1];
     
     
     
     
    for(i=0;i<10;i++)
     
    {
     
      delay(1);
     
      rd=1;
     
      wr=0;
     
      delay(1);
     
      wr=1;
     
      while(intr==1);
     
      rd=0;
     
      lcd_cmd(0x88);
     
      test_intermediate1=adc_input/10;
     
      delay(1);
     
      intr=1;
     
    }
     
    for(i=0;i<10;i++)
     
    test_intermediate2[2]=test_intermediate1+test_intermediate2[2];
     
     
     
     
    test_intermediate2[0]=test_intermediate2[0]/3;
     
    test_intermediate2[1]=test_intermediate2[1]/3;
     
    test_intermediate2[2]=test_intermediate2[2]/3;
     
    test_final=test_intermediate2[0]+test_intermediate2[1]+test_intermediate2[2];
     
    shape();
     
    convert();
     
    }
     
     
     
     
    void main()
     
    {
     
    int k;
     
    start=1;
     
    dig_hr1=1;
     
    dig_min1=1;
     
    alarm_set=1;
     
    alarm=0;
     
    lcd_cmd(0x83);
     
    lcd("SET ALARM");
     
    lcd_cmd(0xc3);
     
    lcd_data_int(hr1);
     
    lcd_data(':');
     
    lcd_data_int(min1);
     
    while(alarm_set==0)
     
    {
     
      delay(10);
     
      if(dig_hr1==0)
     
      set_alarm_hr1();
     
      if(dig_min1==0)
     
      set_alarm_min1();
     
    }
     
     
     
     
    if(am_pm==0)
     
    {
     
      lcd_cmd(0xc8);
     
      lcd_data_string("am");
     
      alarm_am_pm=0;
     
    }
     
     
     
     
    if(am_pm==1)
     
    {
     
      lcd_cmd(0xc8);
     
      lcd_data_string("pm");
     
      alarm_am_pm=1;
     
    }
     
    delay(200);
     
    lcd_cmd(0x01);
     
    lcd_cmd(0x83);
     
    lcd("SET TIMING");
     
    lcd_cmd(0xc3);
     
    lcd_data_int(hr1);
     
    lcd_data(':');
     
    lcd_data_int(min1);
     
    while(start==0)
     
    {
     
      delay(10);
     
      if(dig_hr1==0)
     
      set_hr1();
     
      if(dig_min1==0)
     
      set_min1(); 
     
    }
     
     
     
     
    if(am_pm==0)
     
    {
     
      lcd_cmd(0xc8);
     
      lcd_data_string("am");
     
      dig_am_pm=0;
     
    }
     
     
     
     
    if(am_pm==1)
     
    {
     
      lcd_cmd(0xc8);
     
      lcd_data_string("pm");
     
      dig_am_pm=1;
     
    }
     
    delay(200);
     
    lcd_cmd(0x01);
     
    while(1)
     
    {
     
      for(k=0;k<2;k++)
     
      {
     
       for(hr=hr1;hr<12;hr++)
     
       {
     
        for(min=min1;min<60;min++)
     
        {
     
         for(sec=0;sec<60;sec++)
     
         {
     
          lcd_cmd(0x81);
     
          delay(1);
     
          lcd_data_int(hr);
     
          lcd_data(':');
     
          lcd_data_int(min);
     
          lcd_data(':');
     
          lcd_data_int(sec);
     
          if(dig_am_pm==0)
     
          {
     
           lcd("am");
     
          }
     
          else
     
          {
     
           lcd("pm");
     
          }
     
          alarm_check();
     
          lcd_cmd(0xc3); 
     
          delay(2);
     
          lcd_data_string("TEMP:");
     
          temp();
     
          lcd_data_string("    ");
     
         }
     
        }
     
       min1=0;
     
       }
     
      if(dig_am_pm==0)
     
      dig_am_pm=1;
     
      else
     
      dig_am_pm=0;
     
      hr1=0;
     
      }
     
    }
     
     
    }

     

    April 4, 2017 at 10:12 am #14554
    indrajeet Tmabe
    Participant

    please provide me a solution….

    December 12, 2017 at 5:29 am #14678
    sharon
    Participant

    Connect the 4×4 keypad with port 1 of the microcontroller. Connect 16×2 LCD display with port 2 of the microcontroller (make sure that all the data pins of LCD display are connected to the microcontroller correctly). The rs (register set) pin of  LCD is connected to pin 3.5 (pin number: 15) and en (enable) pin is connected to pin 3.6 (pin number 16) of the microcontroller. Connect crystal to pin 18 and 19 of the microcontroller. We are using 12MHz frequency Crystal. For reset, circuitry connects a pushbutton to pin 9 of the microcontroller. We can also use a potentiometer to adjust the contrast of LCD.

    Regards , 

    8051 Training in CETPA !!

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Battery discharger May 20, 2026
  • Relay question May 19, 2026
  • Phone Charger 5v to 12v May 19, 2026
  • reviving old swordfish program but? May 18, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 18, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise