Advertisement
Braulio777

Arduino LCD Clock

Jul 6th, 2017
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. //ARDUINO LCD CLOCK
  2. //24:00 hours format
  3. #include <Wire.h>
  4. #include <LiquidCrystal_I2C.h>
  5. LiquidCrystal_I2C lcd(0x27,16,2);
  6. int ss = 0; //seconds
  7. int mm = 40; //minutes, set the time of your area where you live
  8. int hh = 19; //hours, this time is only an example.
  9.  
  10. void setup() {
  11.  lcd.init();                      
  12.   lcd.init();
  13.   lcd.backlight();
  14.   lcd.begin(16, 2);
  15. }
  16.  
  17. void loop() {
  18.   for (ss = 0; ss < 60; ss++) {
  19.     lcd.clear();
  20.     lcd.setCursor(3, 0);
  21.     lcd.print("Hrs");
  22.    
  23.     lcd.setCursor(4, 1);
  24.     lcd.print(hh);
  25.    
  26.     lcd.setCursor(6, 1);
  27.     lcd.print(":");
  28.    
  29.     lcd.setCursor(7, 0);
  30.     lcd.print("Min");
  31.    
  32.     lcd.setCursor(7, 1);
  33.     lcd.print(mm);
  34.    
  35.     lcd.setCursor(9, 1);
  36.     lcd.print(":");
  37.    
  38.     lcd.setCursor(11, 0);
  39.     lcd.print("Sec");
  40.    
  41.     lcd.setCursor(10, 1);
  42.     lcd.print(ss);
  43.         delay(1000);
  44.       }
  45.  
  46. if(ss > 59) {
  47.   ss = 00;
  48.   mm = mm+1;}
  49.   if(mm > 59){
  50.   mm = 00;
  51.   hh = hh+1;}
  52.   if(hh == 24){
  53.     hh = 00;
  54.     mm = 00;
  55.     ss = 00;
  56.   }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement