A MicroPython Class for Debouncing Switches. Read the full blog article.
switch.pyis complete source for the classswitch.mpyis the cross-compiled version for MicroPython v1.9.4.example/main.pyshows an example of the class in action.
I recommend using the cross-compiled version or cross-compiling your own version to save on memory usage. Note that the version it was cross-compiled for must match the version of MicroPython you are running.