/*
### Charlieplexing Simple Clock
Author: Martin Ponson
Version: 1.0 (October 2023)
Base code by: plouc68000
Source: https://projecthub.arduino.cc/plouc68000/simplest-uno-digital-clock-ever-03c185
*/
// Initial time display is 12:59:45 PM
int h = 12;
int m = 59;
int s = 45;
int d = 1; // PM
// Time Set Buttons
int button1;
int button2;
// Pins definition for Time Set Buttons
int hs = A1;// pin A1 for Hours Setting
int ms = A2;// pin A2 for Minutes Setting
// For accurate time reading, use Arduino Real Time Clock (RTC) and not just delay()
static uint32_t last_time, now = 0; // RTC
void setup() {
pinMode(hs,INPUT); // Button 1
pinMode(ms,INPUT); // Button 2
}
void loop() {
// Show initial time >>> LED mapping NEEDED!
// improved replacement of delay(1000)
// Much better accuracy, no more dependant of loop execution time
for (int i=0; i<5; i++) // make 5 time 200ms loop, for faster Button response
{
while ((now - last_time) < 200) // delay200ms
{
now = millis(); // millis overflows after ~50 days >>> possible PROBLEM?
}
// inner 200ms loop
last_time = now; // prepare for next loop
// Button control and time setting
// Block frequency
for (int j=0; j<; j++) {
// LED phase frequency
for (int k=0; k<; k++) {
}
}
}
// outer 1000ms loop
s = s + 1; // Add 1 second, increment sec. counting
// manage seconds, minutes, hours am/pm overflow
if(s == 60){
s = 0;
m = m + 1;
}
if(m == 60){
m = 0;
h = h + 1;
}
if(h == 13){
h = 1;
d = d + 1;
if(d == 2){
d = 0;
}
}
// loop end
}