/* This is a default program--
Use a Push Button to control a Led
*/
const int buttonPin = 2; // sets button pin to pin 2
const int ledPin = 13; // set led pin to pin 13
int buttonState=0;
void setup()
{
pinMode(13,OUTPUT); //sets pin 13 as output
pinMode(2,INPUT); // sets pin 2 as input
}
void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}