Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
This is called button debounce. Youtube is full of videos on this topic with explanations.
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%...
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.
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 questionAsk a Question
731 491 924 answers to any question