Digital Input
The Serial Monitor
Control the LED with two buttons:
and below is my code (feel free to copy and try it on your board.)
const int buttonPin = 2;
const int ledPin = 13;
const int buttonPinTwo = 4;
int buttonState = 0;
int buttonStateTwo = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPinTwo, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
buttonStateTwo = digitalRead(buttonPinTwo);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
}
if (buttonStateTwo == HIGH) {
digitalWrite(ledPin, LOW);
}
}