const int LED1 = 8;
const int LED2 = 9;
const int LED3 = 10;
const int BTN1 = 2;
const int BTN2 = 3;
const int BTN3 = 4;
void setup()
{
Serial.begin(9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
// Кнопки підключені до GND => використовуємо внутрішній pullup
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
pinMode(BTN3, INPUT_PULLUP);
}
void loop()
{
digitalWrite(LED1, digitalRead(BTN1) == LOW ? HIGH : LOW);
digitalWrite(LED2, digitalRead(BTN2) == LOW ? HIGH : LOW);
digitalWrite(LED3, digitalRead(BTN3) == LOW ? HIGH : LOW);
delay(20);
}Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1