// def do pin do led
int led = 4;
// def do pin do botão
int button = 5;
// def da variavel auxiliar para guardar o estado logico do botao
int bot_aux = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// def do led como saida
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//ler estado logico do botao
bot_aux = digitalRead(button);
if (bot_aux == HIGH){
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
}