// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
unsigned long time_passed = 0; // hour, min, sec;
unsigned long last_second = 0;
enum Page {CLOCK, STOPWATCH};
void print_clock() {
lcd.clear();
auto time_stamp = time_passed;
auto seconds = time_stamp % 60;
time_stamp /= 60;
auto minutes = time_stamp % 60;
time_stamp /= 60;
auto hours = time_stamp % 24;
time_passed %
lcd.print(hours);
lcd.print(':');
lcd.print(minutes);
lcd.print(':');
lcd.print(seconds);
}
void setup() {
lcd.begin(16, 2);
}
void loop() {
auto current_time = millis();
auto elapsed_time = current_time - last_second;
if (elapsed_time > 1000){
last_second = current_time;
time_passed++;
print_clock();
}
}