Giter Club home page Giter Club logo

single-gpio-led-button's Introduction

Single GPIO driven LED Push Button

Single GPIO illuminated push button Based on the Debounce example documented below.

This simple circuit uses a single GPIO port to drive an LED in addition to acting as a push button input.

Most of the time the GPIO is configured as an Open Drain output driving the LED, periodically it is switched to an input and the button state is read.

Note:

Whilst the button is pressed the LED will light as it is being turned on by the push button so if the button press is to turn the LED off the it will not actually go off until the push button is released, in practice this is not an esthetic problem.

It is recomended that GPIO used is 5V tollerant however in practice leakage is low and is less than 3V.

Each time the input pin goes from High to LOW (e.g. because of a push-button press), the led state is toggled. There's a minimum delay between toggles to debounce the circuit (i.e. to ignore noise).

The circuit:

  • LED is attached from 5V to GPIO pin via a suitable resistor (suggested 330 ohm for white LED) check the GPIO mA sink rating for your MCU. Older Gallium Arsenide LEDs could be driven from 3.3V.
  • pushbutton attached from GPIO pin to ground

Danger:

This will only work on MCUs that support Open Drain outputs such as the STM32 and SAMD21 as the push button grounds the GPIO pin when pressed, other MCUs such as the ATMEGA328P could be damaged if wired this way. Please observe the maximum sink current of your MCU if you are driving a number of LEDs.

26 November 2019 - David Bottrill

Based on Debounce

created 21 Nov 2006 by David A. Mellis modified 30 Aug 201 by Limor Fried modified 28 Dec 2012 by Mike Walters modified 30 Aug 2016 by Arturo Guadalupi

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Debounce

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.