// Define the LED pins
const int pinkLed = 10; // Pink LED pin
const int lightBlueLed = 8; // Light Blue LED pin
// Define the pushbutton pin
const int buttonPin = 12; // Pushbutton pin
// Variable to store the button state
int buttonState = 0;
// Variable to store the LED state
bool ledsOn = false;
void setup() {
// Initialize the LED pins as outputs
pinMode(pinkLed, OUTPUT);
pinMode(lightBlueLed, OUTPUT);
// Initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
}
void loop() {
// Read the state of the pushbutton
buttonState = digitalRead(buttonPin);
// Check if the pushbutton is pressed
if (buttonState == HIGH) {
// Toggle the state of the LEDs
ledsOn = !ledsOn;
// Wait for button release to avoid multiple toggles
while (digitalRead(buttonPin) == HIGH) {
delay(10); // Debounce delay
}
// Set the LEDs according to the toggled state
if (ledsOn) {
digitalWrite(pinkLed, HIGH);
digitalWrite(lightBlueLed, HIGH);
} else {
digitalWrite(pinkLed, LOW);
digitalWrite(lightBlueLed, LOW);
}
}
}