const int pinLED = 33;
const int button = 18;
bool state = false ;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(pinLED, OUTPUT);
pinMode(button, INPUT_PULLUP);
Serial.println("Hello, ESP32!");
}
void loop() {
Serial.println(state);
if (digitalRead(button) == LOW && state == false){
state = true;
}else if (digitalRead(button) == LOW && state == true){
state = false;
}
if(state == false){
digitalWrite(pinLED, LOW);
}
if(state == true){
digitalWrite(pinLED, HIGH);
}
delay(100);
}
//button pin pullup