Contenu remplacé par « {{MicroPython-Hack-Prepare-NAV}} {{MicroPython-Hack-deparasitage-core}} {{MicroPython-Hack-deparasitage-TRAILER}} »
Ligne 1 :
Ligne 1 :
{{MicroPython-Hack-Prepare-NAV}}
{{MicroPython-Hack-Prepare-NAV}}
−
{{traduction}}
+
{{MicroPython-Hack-deparasitage-core}}
−
−
{{bloc-etroit|text=A pin used as input from a switch or other mechanical device can have a lot of noise on it, rapidly changing from low to high when the switch is first pressed or released. This noise can be eliminated using a capacitor (a debouncing circuit). It can also be eliminated using a simple function that makes sure the value on the pin is stable.
−
−
The following function does just this. It gets the current value of the given pin, and then waits for the value to change. The new pin value must be stable for a continuous 20ms for it to register the change. You can adjust this time (to say 50ms) if you still have noise.