Last active
August 16, 2017 14:43
-
-
Save Nsk1107/ef0a3bf30129ad90fa4be2be0bee1292 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <LiquidCrystal.h> | |
| LiquidCrystal lcd(7, 6, 5, 4, 3, 2); | |
| int starttime; | |
| int activetime; | |
| int prevoustime = 0; | |
| //set time before compile+++++++++++ | |
| int hours = 19; | |
| int mins = 55; | |
| int sec = 55; | |
| String flag = "PM"; | |
| //+++++++++++++++++++++++++++++++++ | |
| int fhours = hours - 12; | |
| void setup() | |
| { | |
| lcd.begin(16, 2); | |
| lcd.clear(); | |
| //Serial.begin(9600); | |
| starttime = millis() / 1000; | |
| } | |
| void loop() | |
| { | |
| activetime = (millis() / 1000) - starttime; | |
| if (prevoustime < activetime) | |
| { | |
| sec++; | |
| prevoustime = activetime; | |
| } | |
| if (sec > 59) | |
| { | |
| mins++; | |
| sec = 0; | |
| } | |
| if (mins > 59) | |
| { | |
| hours++; | |
| mins = 0; | |
| } | |
| if (hours > 12) { | |
| fhours = hours - 12; | |
| flag = "PM"; | |
| } else { | |
| fhours = hours+1; | |
| flag = "AM"; | |
| } | |
| if (hours > 23) | |
| { | |
| hours = 0; | |
| } | |
| char str[12]; | |
| sprintf(str, "%02d:%02d:%02d %s", fhours, mins, sec, flag.c_str()); | |
| //Serial.println(str); | |
| lcd.print(str); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment