504Views12Replies
Debounce arduino push button sketch
Hi,
I have done the following sketch and wiring, i have tried all sorts of Debounce code in the sketch but can't get it to stop.
Most of the sketches i have read and tried switch the led on with one push and off with the second. i just want it to stay on while being pushed and go off while not being pushed, i am working towards RF or Bluetooth but not until i stop this bounce!
Discussions
5 years ago
To properly troubleshoot this, start with only one arduino to get the switch to turn the LED on and off on the same board with the switch.
Reply 5 years ago
It does do that its just serial communication that seems to be the problem
Reply 5 years ago
http://robotic-controls.com/learn/arduino/arduino-...
crossed wires between two arduinos TX-RX, RX-TX, shared ground like MikeR3 suggested.
Reply 5 years ago
tried that too, thanks btw @MikeR3
Reply 5 years ago
I dunno, maybe you have to tweak the delays from that sample code to allow it to communicate.
Reply 5 years ago
thanks for your help, i had to put a command in to go low if serialprint K was not there, also i needed a delay to ge e voltage p for some reason b all sorted now!
5 years ago
LED it now on pin 8 and he if is changed to a while.
5 years ago
Thanks, gave them all a try but still the same!
someimes is works sometimes not, i just want it to work wiles being pushed
5 years ago
Also, run the program while looking at the serial monitor, whenever I set up a pull-up resistor switch situation, you can never be sure if it goes high when pressed or is low in its unpressed state. You can set up the switch using the internal pullup on certain arduino pins without the added resistor. Depending on the Arduino, it may return a value opposite of what you expect.
5 years ago
First thing I would do:
In the Rx system, use a pin other than 13. Change the wiring and the "int led =13;" to some other DIO pin.
I'm not sure if that's your problem, but I've always had problems at boot with using pin13.
Reply 5 years ago
Also ground both arduinos to the same bus.
Reply 5 years ago
Also, you're only using one wire for the communication. You might need to connect Tx to Rx and Rx to Tx for the protocol to work. Just a thought.