silvia11931Tommaso Martorella
Published © GPL3+

Interrupts Debouncing with Zerynth (Python for IoT)

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

BeginnerFull instructions provided1 hour2,656
Interrupts Debouncing with Zerynth (Python for IoT)

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

Story

Read more

Schematics

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)

Credits

silvia11931

silvia11931

10 projects • 9 followers
Tommaso Martorella

Tommaso Martorella

8 projects • 4 followers

Comments