dogfood-timer updated to remove the chance (1/350) of the arduino skipping a second while the display is supposed to turn off or change the day. Side effect is that the arduino is actually more accurate at keeping time.

master
Cole Deck 6 years ago
parent e0eb0be69b
commit 69013515ed

@ -192,7 +192,7 @@ void setuptime() {
} }
delay(250); delay(250);
unsigned long oldtime = 0; unsigned long oldtime = 0;
unsigned long secper5 = now(); unsigned long secper20 = now();
check = false; check = false;
while(1 == 1) { while(1 == 1) {
time_t t = now(); time_t t = now();
@ -212,7 +212,7 @@ void setuptime() {
//Serial.println(distance); //Serial.println(distance);
if(distance < 30 || analogRead(3) >= 150 || digitalRead(7) == 1 || digitalRead(6) == 1) { if(distance < 30 || analogRead(3) >= 125 || digitalRead(7) == 1 || digitalRead(6) == 1) {
digitalWrite(10, HIGH); digitalWrite(10, HIGH);
wait = now(); wait = now();
} }
@ -232,11 +232,17 @@ void setuptime() {
if(now() != oldtime) { if(now() != oldtime) {
//if(check == false) { //if(check == false) {
//Serial.println(analogRead(3)); //Serial.println(analogRead(3));
if(now()-350 >= secper5) { if(now()-1200 >= secper20) {
t = t + 1; if(now()-15 >= wait && analogRead(3) < 100) {
secper5 = now(); digitalWrite(10, LOW); // just in case the arduino skips a second at the wrong time
}
if(day(t) != oldday) {
today = 0;
}
setTime(now() + 1);
secper20 = now();
} }
if(now()-15 >= wait && analogRead(3) < 150) { if(now()-15 >= wait && analogRead(3) < 100) {
digitalWrite(10, LOW); digitalWrite(10, LOW);
} }
if(day(t) != oldday) { if(day(t) != oldday) {
@ -258,7 +264,7 @@ void setuptime() {
lcd.print("PM"); lcd.print("PM");
} */ } */
if (analogRead(3) < 150 && prevphoto >=150) { if (analogRead(3) < 100 && prevphoto >=100) {
last = now(); last = now();
lastlong = now(); lastlong = now();
today ++; today ++;

Loading…
Cancel
Save