const int ledPin = 13; // Pin connected to the LED
const int buttonPin = 2; // Pin connected to the button
void setup()
{
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
pinMode(buttonPin, INPUT); // Set the button pin as an input
}
void loop()
{
while (digitalRead(buttonPin) == HIGH)
{ // While the button is pressed
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(500); // Wait for half a second
digitalWrite(ledPin, LOW); // Turn the LED off
delay(500); // Wait for half a second
}
}