Showing posts with label Button Reading. Show all posts
Showing posts with label Button Reading. Show all posts

Saturday, January 16, 2021

Read and debounce multiple buttons using interrupt on AVR microcontrollers

This library provides an easy way for reading and debouncing one or multiple buttons connected to a microcontroller. Apart from basic functionality, the library provides some extra functions such as reading a combination of buttons, and detecting a button long press or a double pressed button. These are especially useful in a low button count system.

Multiple buttons can also be read by a single ADC pin.


Button debouncing library for AVR microcontrollers

Contents

 

What is button debouncing

Tuesday, May 8, 2018

Library for reading multiple buttons with 1 ADC pin | AVR microcontrollers

There are many ways of reading switches, and one of them is using ADC pins. The advantages of this method is that it uses very low pin count compared to other methods, and all is needed are switches, resistors and an ADC (analog to digital converter). With a 10bit ADC, at least 20 switches can be used per pin.

To read the buttons the conventional way where every button is connected directly to a GPIO pin, check out this other library https://www.programming-electronics-diy.xyz/2021/01/button-debouncing-library-for-avr.html.

Library Features

  • Supports multiple groups of buttons on different ADC pins
  • Ability to read combination of multiple button press on different ADC pins
  • Can have different number of buttons on each pin
  • Check if a button was pressed for a certain amount of time
  • Timer 2 and ADC is setup by default 

Reading buttons using ADC (configuration #1)

Reading buttons using ADC - Configuration 1
Fig. 1 Reading buttons using ADC (configuration #1)