For Stairway Lighting: Arduino LED Control with Push Buttons | Example Code | English Subtitle

preview_player
Показать описание
For Stairway Lighting: Arduino LED Control with Push Buttons | Example Code | English Subtitle
You can use a Relay to control High watt equipements,
Code : code is on the comment below.
Please Subscribe my Channel. ThankYou!
Рекомендации по теме
Комментарии
Автор

// Define LED and button pins
const int ledPin = 13; // Change this to your desired LED pin
const int buttonPin1 = 2; // Change this to your first button pin
const int buttonPin2 = 3; // Change this to your second button pin

// Define variables to store button state
int buttonState1 = 0;
int buttonState2 = 0;

// Define variable to store LED state
int ledState = LOW;

void setup() {
// Initialize LED and buttons
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
}

void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);

// If either button is pressed, toggle LED state
if (buttonState1 == LOW || buttonState2 == LOW) {
ledState = !ledState;
digitalWrite(ledPin, ledState);
// Delay for button debounce
delay(200);
}
}

doit.
welcome to shbcf.ru