METHOD 5. SOFTWARE DELAY DEBOUNCE


There are numerous examples online for software debounce routines for every computer language known to mankind. They all amount to simply waiting out the estimated bounce period.

For Switch Activated:

  1. Loop until switch activated.
  2. Delay 20 to 100 milliseconds.
  3. Retest to be sure it is still activated. (If not, go to 1)
  4. Continue with the program. Switch is activated.

For Switch Released:

  1. Loop until switch released.
  2. Delay 20 to 100 milliseconds.
  3. Retest to be sure it is still released. (If not, go to 1)
  4. Continue with the program. Switch is released.

You must provide a longer delay period than any switch you use will ever bounce. Contact bounce time varies among switch types and even among switches of the same type and models. Delay time also is said to change over time with the same switch. Typical delay times used are 20 to 100 milliseconds, even when the actual bounce time may be as little as a few milliseconds.

For compute-bound applications where time is literally of the essence, such as in high-speed automated industrial machinery or robotics applications, your choice of debounce method should be Method 1: Two-Pin Debounce, or Method 2: Cross-Coupled Nand Debounce.