Skip to content

Instantly share code, notes, and snippets.

@vikhyat28
Created December 12, 2016 02:58
Show Gist options
  • Save vikhyat28/703b8d9eb6606e28107a4c587c6274fc to your computer and use it in GitHub Desktop.
Save vikhyat28/703b8d9eb6606e28107a4c587c6274fc to your computer and use it in GitHub Desktop.
int h,m,s;
int set_hours=20;
int set_minutes=49;
int set_seconds=45;
int secs=1000;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.print("The Time is!");
}
void printChar()
{
lcd.setCursor(6,1);
lcd.print(s/10);
lcd.setCursor(7,1);
lcd.print(s%10);
lcd.setCursor(3,1);
lcd.print(m/10);
lcd.setCursor(4,1);
lcd.print(m%10);
lcd.setCursor(5,1);
lcd.print(":");
lcd.setCursor(0,1);
lcd.print(h/10);
lcd.setCursor(1,1);
lcd.print(h%10);
lcd.setCursor(2,1);
lcd.print(":");
}
void Clock()
{
for(h=set_hours;h<24;h++) //hOURS
{
for(m=set_minutes;m<60;m++) //mINUTES
{
for(s=set_seconds;s<60;s++) //Seconds
{
printChar();
delay(secs-(millis()%1000));
}
set_seconds=00;
}
set_minutes=00;
}
set_hours=00;
}
void loop()
{
Clock();
}
@vikhyat28
Copy link
Author

This program gives an efficiency of 5seconds shift for every 12 hours due to clock going out of sync. I hope its helpful . Looking forward for corrections and improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment