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 / Digital clock

Digital clock

|

Projects › Projects › Digital clock

  • This topic has 1 reply, 2 voices, and was last updated 12 years, 4 months ago by kishore.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 20, 2013 at 1:40 am #2596
    Zaidshj
    Participant

    I need coding using C+ for digital clock.

    Any help would be appriciated

    December 2, 2013 at 12:33 am #10685
    kishore
    Participant

    hi this clock i made last sem, it shows only the time hh:mm:ss and you can also set the time.

    wysiwyg_imageupload:11129:

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Codes:

    #include<reg51.h>
    sbit p=P3^0;  //hour ++++++++
    sbit q=P3^1;  //hour


    sbit r=P3^2;  //min +++++++
    sbit t=P3^3;  //min


    sbit rs=P2^0;
    sbit rw=P2^1;
    sbit en=P2^2;
     
    void delay(unsigned int msec)
    {
    unsigned int i,j;
    for(i=0;i<msec;i++)
    for(j=0;j<1275;j++);
    }
     
    void cmd(unsigned char item)
    {
    P1=item;
    rs=0;
    rw=0;
    en=1;
    delay(1);
    en=0;
    }
     
    void lcddata(unsigned char item)
    {
    P1=item;
    rs=1;
    rw=0;
    en=1;
    delay(1);
    en=0;
    }
     
    void main()
    {
    int h,m,s,h1,h2,m1,m2,s1,s2;
    unsigned char array[]={‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’};
    cmd(0x38);
    cmd(0x0c);
    cmd(0x06);
    while(1)
    {
    for(h=0;h<=23;h++)
    {
    for(m=0;m<=59;m++)
    {
    for(s=0;s<=59;s++)
    {
    h1=h/10;
    h2=h%10;
    m1=m/10;
    m2=m%10;
    s1=s/10;
    s2=s%10;
    cmd(0x80);
    lcddata(array[h1]);
    lcddata(array[h2]);
    cmd(0x84);
    lcddata(‘:’);
    cmd(0x86);
    lcddata(array[m1]);
    lcddata(array[m2]);
    cmd(0x8A);
    lcddata(‘:’);
    cmd(0x8C);
    lcddata(array[s1]);
    lcddata(array[s2]);
    delay(100);
     
    if(p==0)   //hour++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    {
    h++;
    s=-1;
    if(h==24)
    {
    h=0;
    s=-1;
    }
    }
    else if (t==0) //min


    {
    if(m>0)
    {
    m–;
    s=-1;
    }
    }
    else if(q==0)  //hour


    {
    if(h>0)
    {
    h–;
    s=-1;
    }
    }
    else if (r==0) //min ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    {
    m++;
    s=-1;
    if(m>60)
    {
    m=0;
    s=-1;
    }
    }
    cmd(0x82);
    cmd(0x06);
    }
    }
    }
    }
    }
     
     
     
     
     
    If you want the date also then follow this link http://www.youtube.com/watch?v=vufmCLIykjYs 
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • compile errors April 22, 2026
  • Quick Tip: Handling CH340 Driver Issues on Uno SMD Clones April 22, 2026
  • My Advanced Realistic Humanoid Robots Project April 22, 2026
  • Getting into an LED bulb April 21, 2026
  • understanding of resonance in time domain April 21, 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