// Define pin numbers
const int switchPin = 2; // Switch connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13 (built-in)
void setup() {
pinMode(switchPin, INPUT); // Set switch pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
int switchState = digitalRead(switchPin); // Read switch status
if (switchState == HIGH) {
digitalWrite(ledPin, HIGH); // If switch is pressed, turn LED ON
} else {
digitalWrite(ledPin, LOW); // If switch is not pressed, turn LED OFF
}
}