Coder Social home page Coder Social logo

bdubs-astro / upy_debounce_switch Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 254 KB

debounce a switch using interrupts

Python 100.00%
debounce debounce-button debounce-input debouncer interrupt-driven-programs interrupt-handler pulldown pullup raspberry raspberry-pi

upy_debounce_switch's Introduction

uPy_Debounce_Switch

Debounce a switch using interrupts.


Creates an interrupt handler that's called when the switch pin changes state (i.e., rising or falling edge trigger). If a debounce cycle has not already been started, the handler creates a one-shot timer. While this timer is running, any additional interrupts are ignored. After the timer expires, the desired action is taken (i.e., the sw_callback function is called), and the debounce cycle is cleared so it can begin again.

switch.irq(handler=sw_event, trigger=Pin.IRQ_FALLING|Pin.IRQ_RISING)

debounce_timer.init(mode=Timer.ONE_SHOT, period=debounce_delay, callback=debounce_clear)

Resources:

https://docs.micropython.org/en/latest/library/machine.Pin.html?highlight=pin#machine.Pin

https://docs.micropython.org/en/latest/library/machine.Timer.html



https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html


Digital Inputs: Pullup vs. Pulldown Resistors

upy_debounce_switch's People

Contributors

bdubs-astro avatar bdwissman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.