Hello guys i'm new in the arduino world but i already have big projects in mind! I'm building a simple automatic hay feeder for my horses, it's basically something like this but with just 2 floors,
Every 24hrs (at 6am) a servo should make the plate in the middle fall and the hay should fall down, the problem i have is with the timer, it' should be a very simple interface with 3 buttons a green button to start the timer when pressed, a red button to reset the timer and a blue button to eventually reset the servo to lock the plate again , but i'm struggling with the timer right now
const int greenB = 2;
const int redB = 3;
int inAction = 0;
int greenState = 0;
int redState = 0;
void setup() {
Serial.begin(9600);
pinMode(greenB, INPUT);
pinMode(redB, INPUT);
}
void loop() {
greenState = digitalRead(greenB);
redState = digitalRead(redB);
if(greenState == HIGH){
inAction = 1;
while(inAction == 1){
for(int i = 0; i<10;i++){
if(i == 10){
Serial.println("Cycle completed");
}
if(redState == HIGH){
Serial.println("timer stopped");
goto stopTimer;
}
Serial.println("10 seconds timer");
delay(1000);
}
stopTimer: Serial.println("timer stopped");inAction = 0;
}
}
}
What it should do is to start the timer the moment i pressed it and do the cycle every 24hrs (i put 10 seconds now to test it) when i press the green button it starts but it sops after 10 seconds and it should stop only when i press the red button...what am i doing wrong?
here is the console