|
|
@ -34,27 +34,29 @@ void setup() { |
|
|
|
sevseg.setBrightness(10); |
|
|
|
pinMode(A5, INPUT_PULLUP); |
|
|
|
pinMode(A1, INPUT_PULLUP); |
|
|
|
// Serial.begin(9600); // debugging
|
|
|
|
Serial.begin(9600); // debugging
|
|
|
|
} |
|
|
|
|
|
|
|
int decPlaces = 3; |
|
|
|
int decPlaces = 1; |
|
|
|
float lastReset = 0; // optional button reset - orange wire connected to A1, or programmable button on A5
|
|
|
|
|
|
|
|
void loop() { |
|
|
|
unsigned long runMillis= millis(); |
|
|
|
float actualDays = runMillis/86400000.0; |
|
|
|
float days = actualDays - lastReset; |
|
|
|
sevseg.setNumber(days, decPlaces); |
|
|
|
sevseg.setNumber(days*pow(10,decPlaces), decPlaces); |
|
|
|
sevseg.refreshDisplay(); // Must run repeatedly
|
|
|
|
// Serial.println(actualDays,5); // debugging
|
|
|
|
// Serial.print(actualDays,5); // debugging
|
|
|
|
// Serial.print(' ');
|
|
|
|
// Serial.println(days,4);
|
|
|
|
// Serial.println(digitalRead(A1)); // debugging
|
|
|
|
if(!digitalRead(A1)){lastReset -= 0.001;} |
|
|
|
if(!digitalRead(A1)){lastReset -= 0.0005;} |
|
|
|
// if(!digitalRead(A5)){lastReset = actualDays;}
|
|
|
|
// program A5 as decimal place changer
|
|
|
|
if(!digitalRead(A5)){ |
|
|
|
// if(decPlaces == 2){decPlaces = 3;}
|
|
|
|
// if(decPlaces == 3){decPlaces = 2;}
|
|
|
|
decPlaces = (decPlaces + 1)%2 + 2; |
|
|
|
decPlaces = (decPlaces + 1)%4; |
|
|
|
delay(250); |
|
|
|
} |
|
|
|
} |
|
|
|