Interrupts Debouncing with Zerynth (Python for IoT)

Summary of Interrupts Debouncing with Zerynth (Python for IoT)


This tutorial demonstrates advanced interrupt debouncing using Zerynth and an Arduino MKR1000 board. It uses PWM signals on connected pins D2 and D3, employing Zerynth Studio to program the microcontroller in Python. Interrupts trigger only when the signal remains stable for the debounce time, filtering out noise during fall and rise events. The tutorial includes hardware setup, code examples, and serial monitoring to observe interrupt debounce behavior, facilitating robust IoT environment development.

Parts used in the Interrupt Debounce Project:

  • Arduino MKR1000
  • Jumper wires (generic)
  • Zerynth Studio (software)

In this tutorial, we’ll see the advanced feature of interrupt debouncing using Zerynth.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Schematics

Code

main.py

Python

################################################################################
# Interrupt Debounce
#
# Created by Zerynth Team 2015 CC
# Authors: G. Baldi, D. Mazzei
################################################################################

# import streams
import streams
# import pwm for testing
import pwm


# CONNECT pin D3 to PIN D2 for this example to work!

streams.serial()

def on_touch_up():
    print("touched UP")

def on_touch_dn():
    print("touched DN")
    

    
try:    
    # D2 will call touch_up on rise and touch_dn on fall with different debounce times
    onPinRise(D2,on_touch_up,debounce=500)
    onPinFall(D2,on_touch_dn,debounce=300)
except Exception as e:
    print(e)




while True:
    for x in [100,200,300,400,500,600,700,800,900]:
        print("--->",x, 1000-x)
        # start pwm on D3 with the current period
        pwm.write(D3.PWM,1000,x)
        # now wait and check if debounce is working
        sleep(5000)

 

Source : Interrupts Debouncing with Zerynth (Python for IoT)


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top