Arduino – CLCD with I2C – Time (999 Seconds)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); unsigned long timeSecond=0; int timeLength=0; void setup() { lcd.init(); delay(1000); lcd.backlight(); lcd.setCursor(0,0); lcd.print("Seconds : "); } void loop() { timeSecond=(millis() / 1000) % 1000; timeLength=String(timeSecond).length(); lcd.setCursor(10, 0); for (int i=0;i<3-timeLength;i++) { lcd.print(" "); } lcd.print(timeSecond); lcd.print("s"); } |