Please help
Hi, my project is simple, activate one output 2 minutes per hour.
My problem is, when the Arduino reach the 2 seconds it freezes and it does not reset itself, even i can't reset manually, i have to turn it off and it will work again.
#include <avr/wdt.h> //watchdog
int segun =0;
int minut =0;
byte venti = 3;
byte led = 13;
void setup() {
wdt_enable(WDTO_2S); //watchdog timer with 2 Seconds time out
//Serial.begin(9600);
pinMode(venti, OUTPUT);
}
void loop() {
//Serial.print(minut);Serial.print(":");Serial.println(segun);
if(segun >= 60){minut++;segun = 0;}
if(minut >= 60){minut = 0;}
if(minut <= 1 ){ // 1 es 2 de 60 minutos ON
digitalWrite(venti, HIGH);digitalWrite(led, HIGH);}
else{ digitalWrite(venti, LOW);digitalWrite(led, LOW);}
delay(997); // deberia ser 1 segundo aproximadamente
segun++;
wdt_reset();
}
i put this to test the whatchdog but it fails:
//to test whatchdog:
if(segun>=10){
delay(997);
delay(997);
delay(997);
delay(997);
delay(997);}