I'm trying to display values 1,2,3,4 on serial monitor whenever I press the push button once. I used if switch condition for that. But I can only print 1,3 each time I press and leave the pushbutton. if I hold the push button, its printing 2,4 too. but if I leave it only prints 1,3.
below is my code. plz help. I found if I use a switch instead of push-button, it works good, with all 4 numbers 1,2,3,4 printing.
This tests whether the button state has changed. In order to act only when the button becomes pressed you also need to test whether it is in that state after the change
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?