// Define pin numbers
const int ledPin = 11; // Pin connected to the LED
const int buttonPin = 8; // Pin connected to the switch
void setup()
{
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(buttonPin, INPUT); // Set the button pin as input
}
void loop()
{
int buttonState = digitalRead(buttonPin);
// Read the state of the button
if (buttonState == HIGH) { // If the button is pressed
digitalWrite(ledPin, HIGH); // Turn on the LED
} else { // If the button is not pressed
digitalWrite(ledPin, LOW); // Turn off the LED
}
}