void loop()
{
int buttonState = digitalRead(buttonPin); //read and store the button state (0 or 1)
if(buttonState == HIGH){ //check if state is high (button is pressed)
digitalWrite(LED1,HIGH); //turn on LED
} else {
digitalWrite(LED1,LOW); //turn off LED
}}
So how exactly is the input wired ?
Is anything keeping the input LOW when the button is not pressed or is it floating at an unknown voltage, maybe HIGH, maybe LOW, maybe changing ?