403Views12Replies

Author Options:

Debounce arduino push button sketch Answered

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

0
None
caitlinsdad

4 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.

0
None
Senkencaitlinsdad

Reply 4 years ago

It does do that its just serial communication that seems to be the problem

0
None
caitlinsdadSenken

Reply 4 years ago

I dunno, maybe you have to tweak the delays from that sample code to allow it to communicate.

0
None
Senkencaitlinsdad

Reply 4 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!

0
None
Senken

4 years ago

LED it now on pin 8 and he if is changed to a while.

0
None
Senken

4 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

0
None
caitlinsdad

4 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.

0
None
MikeR3

4 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.

0
None
MikeR3MikeR3

Reply 4 years ago

Also ground both arduinos to the same bus.

0
None
MikeR3MikeR3

Reply 4 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.