#define BUTTON_PIN 21 // GPIO21 pin connected to button
// Variables will change:
int lastState = HIGH; // the previous state from the input pin
int currentState; // the current reading from the input pin
void setup() {
// initialize the pushbutton pin as an pull-up input
pinMode(BUTTON_PIN, INPUT_PULLUP);
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop() {
// read the state of the switch/button:
//currentState = digitalRead(BUTTON_PIN);
//if(lastState == LOW && currentState == HIGH)
// Serial.println("The state changed from LOW to HIGH");
// save the last state
//lastState = currentState;
// read the state of the switch/button:
int buttonState = digitalRead(BUTTON_PIN);
// print out the button's state
Serial.println(buttonState);
}