PCEval / esp32 /level3 /button_led /src /main_esp.cpp
eunzee's picture
upload Arduino Uno and ESP32 project files
8e53a3e verified
Raw History Blame Contribute Delete
476 Bytes
/**
Press the button to turn on the LED
31 Mar 2025 by Blind Author
*/
#include <Arduino.h>
const int BUTTON_PIN = 2;
const int LED_PIN = 13;
void setup() {
Serial.begin(9600);
Serial.println("Button LED test starts");
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState == LOW) {
digitalWrite(LED_PIN, HIGH);
}
else {
digitalWrite(LED_PIN, LOW);
}
}