I simply want to trigger some event when a button is pressed (circuit closed.) I have a wire going from pin 9 to one side of the button and 5v to the other side. I then set pin 9 as a digital input and monitor that pin from the Serial Monitor.
When the button is pressed, everything works perfectly, the Serial Monitor reads a "1" to indicate it is pressed. The problem is that when the button is released, it should just read "0" as the connection is interrupted, but as I view it on the Serial Monitor, the input is toggling quickly between 0's and 1's.
I thought maybe I'd get more precision if I used an Analog read on an anolog pin, but similar problem. When the button is pressed, it reads 1023, the problem is that when it's depressed, the reading changes to a lower number, which is fine, but sometimes jumps up to 1023 and shows a "false" button pressed reading.
I'm assuming both of these are happening because there is some "noise" on the line - any suggestions on getting this fixed.
Ultimately my project is lighting various patterns on an led strip and having the pattern change using a case switch every time the button is pressed. My issue of course is getting that clean reading for the button being pressed.
Any help would be appreciated.