We are working on a project for an engineering class and we are trying to do a simple input output circuit however the light is flickering on and off even when there is no input. We have tried two different uno boards and a mini. Ultimately we want this code to be able to work on the mini. The code is in the attachment if someone could take a look at it and let us know what we are doing wrong it would be very helpful. Thank you.
I'm guessing from its name that your PNG shows a picture of some text. Don't post pictures of text. Just copy and paste the text and to make it easy for people to help you please use the code button </>
The easiest solution is to use the [u]optional-internal pull-up resistors[/u]. But, you'll have to re-wire the switch so pulls the input down to ground, and you'll have to reverse your program logic so that input-low turns the LED on.
[]BTW -[/b] You don't have to turn the LED off after the delay because the loop is going to immediately start-over, read the switch again and turn the LED on or off depending on buttonState.
...And, do you really need the delay? Or, if you want to blink the LED you'll need another delay after you turn it off (and you'll want more than 10mS).