I have a button, which is essentially a switch, and I've got it set up as a pull-down. I have some simple arduino code that reads the corresponding pin and if it is HIGH, it turns on the LED_BUILTIN.
I press the button. Nothing happens.
Code: Select all
int btn11Pin = 11;
int btn11State = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(btn11Pin, INPUT);
}
void loop() {
btn11State = digitalRead(btn11Pin);
if (btn11State == HIGH) {
digitalWrite(LED_BUILTIN, HIGH);
} else {
digitalWrite(LED_BUILTIN, LOW);
}
}