How to De-Bounce Switches on the Arduino - Ultimate Guide to the Arduino #21

Sdílet
Vložit
  • čas přidán 24. 04. 2023
  • 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 CZcams channel page to watch the entire series!
    Get the 3-in-1 Arduino Smart Car and IOT Learning Kit from SunFounder here:
    www.sunfounder.com/products/s...
    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.com/products/7...
    Visit the webpage for this video tutorial on Circuit Basics for wiring diagrams and example code:
    www.circuitbasics.com/how-to-...
    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.circuitbasics.com
    Facebook: / circuitbasic
    Twitter: / circuitbasics
    Instagram: / circuitbasics
  • Věda a technologie

Komentáře • 9

  • @MartinBgelund
    @MartinBgelund Před rokem +3

    Thanks.
    You should make an example of debouncing when using hardware interrupts. Nobody uses polling for button presses.

  • @JamesFraley
    @JamesFraley Před 6 měsíci

    Great video! Very informative.

  • @mikeduino4596
    @mikeduino4596 Před 7 měsíci +2

    Actually the 7414 output on your timing diagram should be flipped, as the Schmitt trigger is an inverter. Otherwise, it is correct.

  • @ericgrante7043
    @ericgrante7043 Před rokem +2

    hello, good video. thanks

  • @DesertVox
    @DesertVox Před rokem +5

    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!

    • @reyhurm
      @reyhurm Před rokem

      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?

    • @DesertVox
      @DesertVox Před rokem

      @@reyhurm Yes, this simple solution is for registering a simple button press. You can add a counter after each delay.

    • @eyehatedog
      @eyehatedog Před 9 měsíci +1

      delay is bad, it stop the whole code!