int pot1; int valor1; int botao1 = 6; int flag1 = 0; int tempo = 0; int rele1 = 13; void setup() { Serial.begin(9600); pinMode(botao1, INPUT_PULLUP); pinMode(rele1, OUTPUT); } void loop() { pot1 = analogRead(A0); valor1 = map(pot1, 0, 1023, 0, 62); botao1 = digitalRead(6); if (botao1 == LOW) { flag1 = 1; digitalWrite(rele1, HIGH); delay(150); } while (flag1 == 1) { contagem1(); } tempo = valor1 + 1; } void contagem1() { tempo--; if (tempo < 0) { tempo = 0; flag1 = 0; digitalWrite(rele1, LOW); } delay(1000); }