M
M
Maxim2014-09-25 05:20:34
Arduino
Maxim, 2014-09-25 05:20:34

How to protect the button on the Arduino from false positives?

There is an arduino, a button is soldered to it, through a long cable (15-20 meters), so the problem is quite predictable.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2014-09-25
@daapp

This is called button debounce. Youtube is full of videos on this topic with explanations.

S
Sergey Petrikov, 2014-09-25
@RicoX

Hardware: wiki.amperka.ru/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE%D1%...
Software: wiki.amperka.ru/%D0%B2%D0%B8 %D0%B4%D0%B5%D0%BE%D1%...

A
artanets, 2014-09-25
@artanets

You can write code to check the button press time, false positives are usually very short.
Set a function in which, while the button is pressed, +1 will constantly be added until a number (100, 200, 10000 of your choice) is reached, if the button is pressed, reset the number to 0.
This method does not slow down the system, but is very dependent on pauses (delay) in code.
If the speed of the code is not very important, then you can simply check the button press after a pause in time.
You can also reverse the button, that is, do not apply current to it, since it is already there by default, but ground it through the button to the ground, instead of a pull-up resistor, in the code use the pinMode( 3 , INPUT_PULLUP); in the part where void setup(). This command reverses the value.
In general, the last method has proven to be more efficient in practice, but there are exceptions depending on what else is included in your arduino.

Y
Yaroslav, 2014-10-12
Ohty @jar_ohty

Connect a button along a long cable - for this, excuse me, you need a candelabra. There is no interference there, as if the port did not burn out. It is necessary to organize powerful protection with diodes and proper grounding, and pressing the button should let a good current flow through the circuit - 20 milliamps. and radio "Mayak").

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question