Pushbutton LED Code in C
intbuttonState = 0;
void setup() {
// initialize the LED pin as an output:
pinMode(13, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(11, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(11);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(13, HIGH);
} else {
// turn LED off:
digitalWrite(13, LOW);
}
}