In this tutorial, we’ll see the advanced feature of interrupt debouncing using Zerynth.
Things used in this project
In this tutorial, we’ll use PWM to show the advanced feature of interrupt debouncing. PWM triggers fall and rise events at different speeds, but interrupts are triggered only if the debounce time (the stable time after and event) is in the correct range.
We’ll use Zerynth Studio to program the microcontroller-based board in Python.
Zerynth simplifies and speeds up IoT development allowing programming in Python or hybrid C/Python the most popular 32-bit microcontrollers and connecting them to the leading Cloud Infrastructures like AWS, Google Cloud, Microsoft Azure, IBM Watson, Ubidots, and many more.
Required Material
You need a board. You can select one of the 32-bit microcontroller devices supported by Zerynth. We’ve chosen the Arduino/Genuino MKR1000 (read Zerynth documentation here).
You also need:
Zerynth Studio, a powerful IDE for embedded programming in Python that enables the IoT. You can download it here.
Assembling
Connect pin D2 to D3 with a jumper. See the schematics.
Programming
Once you have installed Zerynth Studio and created a Zerynth user, you have to register and virtualize the board.
Clone and uplink the Zerynth example “Interrupts Debounce” as shown in the video. Open the Serial Monitor to see the interrupts printouts.
onPinRise and onPinFall are defined as follows
onPinFall(pin, fun, *args, debounce=0, time_unit=MILLIS)
onPinFall(pin, fun, *args, debounce=0, time_unit=MILLIS)
debounce and time_unit are used to define a timeout such that fun is called only if pin stays high for all the duration of the timeout.
Schematics
Code
Source : Interrupts Debouncing with Zerynth (Python for IoT)