// Define the pins for LEDs and bottons
const int LED1Pin = 16;
const int LED2Pin = 17;
const int button1Pin = 2;
const int button2Pin = 0;
const int button3Pin = 4;
// Variables to store LED states
bool led10n = false;
bool led20n = false;
void setup() {
// Initialize LED pins as outputs
pinMode(LED1Pin, OUTPUT);
pinMode(LED2Pin, OUTPUT);
// Initialize button pins as inputs
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
pinMode(button3Pin, INPUT_PULLUP);
}
void loop() {
// Check button 1 state
if (digitalRead(button1Pin) == LOW) {
// Button 1 pressed, toggle LED1
led10n = !led10n;
digitalWrite(LED1Pin, led10n ? HIGH : LOW);
delay(200); // Debouncing delay
}
// Check button 2 state
if (digitalRead(button2Pin) == LOW) {
// Button 2 pressed, toggle LED2
led20n = !led20n;
digitalWrite(LED2Pin, led20n ? HIGH : LOW);
delay(200); // Debouncing delay
}
// Check button 3 state
if (digitalRead(button3Pin) == LOW) {
// Button 3 pressed, turn on both LEDs
led10n = true;
led20n = true;
digitalWrite(LED1Pin, HIGH);
digitalWrite(LED2Pin, HIGH);
delay(200); // Debouncing delay
}
}