int buttonState = 0;
void setup()
{
pinMode(2, INPUT); // Set button as input
pinMode(13, OUTPUT); // Set LED as output
}
void loop()
{
//read the state of the push button
buttonState = digitalRead(2);
//check if push button is pushed.
//if button state is HIGH
if (buttonState == HIGH)
{
// Button pressed: Blink the LED
digitalWrite(13, HIGH);
}
else
{
// Button not pressed: LED off
digitalWrite(13, LOW);
}
delay(10);
}