I would like to know how to go back to a part of the program. In this case I'd like to go back to when s1
is read:
const int s1 = 6;
const int s2 = 7;
const int s3 = 12;
const int m1 = 8;
const int l1 = 11;
int cont = 0;
void setup() {
// put your setup code here, to run once:
pinMode(s1, INPUT_PULLUP);
pinMode(s2, INPUT_PULLUP);
pinMode(s3, INPUT_PULLUP);
pinMode(l1, OUTPUT);
pinMode(m1, OUTPUT);
Serial.begin(9600);
while(digitalRead(s1) == HIGH){
Serial.print("Valor de S1 = ");
Serial.println(s1);
}
digitalWrite(m1, HIGH);
}
void loop(){
if((digitalRead (s2) == LOW) && (cont < 20)){
cont ++;
Serial.print("número de vezes em que o botão foi pressionado:");
Serial.println(cont);
}
else if((digitalRead (s2) == HIGH) && (cont >= 20)){
digitalWrite (m1, LOW);
digitalWrite (l1, HIGH);
delay(5000); //tempo para o LED permanecer acesso
digitalWrite (l1, LOW);
}
}