Is switch debouncing irrelevant on a micro:bit?

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
rhubarbdog
Posts: 40
Joined: Tue Nov 07, 2017 11:45 pm

Is switch debouncing irrelevant on a micro:bit?

Post by rhubarbdog » Mon May 14, 2018 2:57 am

I have produced the following program

Code: Select all

from microbit import *

switch=pin0

display.show("-")

while True:
    if switch.read_digital():
        break

begin=running_time()
bounce=[]

while running_time()-begin<7000:

    display.show(str((running_time()-begin) // 1000))
    
    if not switch.read_digital():
        while not switch.read_digital():
            pass

        if switch.read_digital():
            bounce.append(running_time()-begin)

# write results
display.scroll("bounces: "+str(len(bounce))+"  ")
if bounce:
    display.scroll("(")
    for b in bounce:
        display.scroll(str(b)+",")
    display.scroll(")")
i have tried a micro-switch, a budget slide switch (real cheap and nasty) and simply holding together 2 wires.

I get no bounces. I know if i had a real oscilloscope i'd see bouncing with the last 2 'switches'.

Post Reply