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 / Replies / hi this clock i made last

hi this clock i made last

|

Projects › Projects › Digital clock › hi this clock i made last

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 

RSS Recent Posts

  • Manually actuate fuel tank selector solenoid November 8, 2025
  • JLCPBC are using a different shipping company = less $$$$$$$$ November 8, 2025
  • Help please! BLDC driver circuit using the IR2136s and the STP80NF06 MOSFETS November 8, 2025
  • need two ICs November 8, 2025
  • MLT-8530 Buzzer on ESP32: Why Is the Sound Output Lower Than Expected? November 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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