How to De-Bounce Switches on the Arduino - Ultimate Guide to the Arduino #21
ฝัง
- เผยแพร่เมื่อ 26 ก.ย. 2024
- Switch bounce is a problem with most mechanical switches, but it can be easily fixed on the Arduino using hardware or software solutions. In this video I try several different ways to de-bounce switches on the Arduino and identify which method is the most effective.
This is tutorial #21 in the Ultimate Guide to the Arduino, a complete video course on the Arduino microcontroller with 45 lessons that are designed to teach anyone how to master the Arduino at any skill level. Visit our TH-cam channel page to watch the entire series!
Get the 3-in-1 Arduino Smart Car and IOT Learning Kit from SunFounder here:
www.sunfounder...
Or get the kit from Amazon:
US Amazon: amzn.to/3W1Mahh
DE Amazon: amzn.to/3j0oETn
JP Amazon: amzn.to/3UYrHZG
UK Amazon: amzn.to/3uTJZAC
CA Amazon: amzn.to/3W2vExN
Get the SN74HC14 Schmitt trigger IC from SunFounder here: www.sunfounder...
Visit the webpage for this video tutorial on Circuit Basics for wiring diagrams and example code:
www.circuitbas...
And be sure to check out the Circuit Basics blog and social media for more articles and tutorials on the Raspberry Pi, Arduino and other DIY electronic projects!
www.circuitbas...
Facebook: / circuitbasic
Twitter: / circuitbasics
Instagram: / circuitbasics
Thanks.
You should make an example of debouncing when using hardware interrupts. Nobody uses polling for button presses.
Very Nice tutorial video.
The simplest software debouncing is done using just a delay of about 50 ms. If the digitalRead after that delay is a LOW (assuming the push button is pulled HIGH), then the button has been pressed. But to even further simplify the code, we don't even have to do a second digitalRead. We just assume that the first trigger of the button is enough, because buttons don't get triggered out of nowhere. There has to be button press to trigger the first digitalRead. It's just two lines of code, and that's it, debouncing done!
What do I have to do if I want to count how many times a button is pressed?
Did you realized your solution only works for a single pressing time?
@@reyhurm Yes, this simple solution is for registering a simple button press. You can add a counter after each delay.
delay is bad, it stop the whole code!
Actually the 7414 output on your timing diagram should be flipped, as the Schmitt trigger is an inverter. Otherwise, it is correct.
hello, good video. thanks
Great video! Very informative.
I'm working on a project that uses nema42 and stepper driver. It causes EMI interferences and when the motor starts runing, the other inputs on arduino, even not pressed, they changes randomly and completly desurbes the program.
When i use software debounce with delay function, even at 3ms, it blocs the stepper and vibrating because of the function call evry trigger
We can use the knowledge about delay without blocking programe. I'm talking about millis()
Why not interrupts