Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • In setup(), pinMode(2, INPUT); should be inserted.
  • Place the code for blinking the LED below // do something in the code in Using Digital Input section.

int buttonState = 0;

void setup()
{
pinMode(2, INPUT);
pinMode(11, OUTPUT);
}

void loop()
{
buttonState = digitalRead(2);
if (buttonState == HIGH) {
digitalWrite(11, HIGH);
delay(500); // Wait for 500 millisecond(s)
digitalWrite(11, LOW);
delay(500); // Wait for 500 millisecond(s)
} else {
}
}