#define LED_VERDE 12
#define LED_AMARELO 13
#define LED_VERMELHO 14
#define botao 26
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
for(int i = 12; i < 15; i++){
pinMode(i , OUTPUT);
}
}
void millisLed(int tempoMillis,int LED){
int tempoInicio = millis();
digitalWrite(LED,HIGH);
while(millis()-tempoInicio<tempoMillis){
if(digitalRead(botao)){
Serial.println("Pis");
digitalWrite(LED,LOW);
delay(500);
break;
}
}
digitalWrite(LED,LOW);
}
void loop() {
millisLed(3000, LED_VERDE);
millisLed(3000, LED_AMARELO);
millisLed(3000, LED_VERMELHO);
delay(10); // this speeds up the simulation
}