Hello, Arduino Land!
My code (included) is a variation on BlinkWithoutDelay, where if the timer is up AND the button is pressed, then the LED is turned on until the timer clicks over again. However, I'm getting several bugs. My first version that I uploaded to my Uno Rev3, the button is completely ignored and the LED is constantly powered on. I’ve swapped out the hardware, so there is no issue with the actual components. BlinkWithoutDelay and Button both work seperately.
[Compiling error, solved]
Any ideas on what is going wrong?
blinkandbutton.ino (1.18 KB)
I would represent the "power pin" with a connection to 5V. At least set it to INPUT_PULLUP.
How is your switch and LED wired now?
This is my current set up. I've tripled-checked that all the wires connect.
I think an actual schematic would be orders of magnitude better than the photo, and you should attach the current code to the current post as you update it.
Looks like the pin you are reading your button with is floating when the button is not pressed.
Like LeserMole says, it's hard to tell anything for sure.
Since I’m having struggles with uploading a picture, the wiring is as follows (numbers correlate to digital slot):
12 -> Button. Catty-corner on button ->resistor-> 11. 8 -> LED -> resistor -> GND.
Awesome, that helps a lot.