#define LED_GPIO 2
#define BTN_GPIO 4
bool BTN_State=false; //開關未按下
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(LED_GPIO, OUTPUT);
pinMode(BTN_GPIO, OUTPUT);
}
void loop() {
//read the button state
BTN_State= digitalRead(BTN_GPIO);
//assign the button state to the LED pin
digitalWrite(LED_GPIO, BTN_State);
delay(100); // delay 100 ms. the loop runs at 10Hz
}