Skip to content

dinosd/ArduinoAnalogButtons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ArduinoAnalogButtons

Library for arduino analog buttons

Purpose I made a few things with arduino and in some cases I was missing pins just for buttons. I googled and I found some solutions with very similar implementation. I decided to make my own because ....

My first approach is to be object oriented. The second approach is to turn arduino to event driven programming. I really want the void loop() clear with no logic inside.

Theory This schematic is simply a voltage divider. The library calculates the value should the analog pin have, based on the input voltage and the resistor values. When you call the addButton the calculation is done and stored in the appropriate object.

The loop function reads the analog port and finds which voltage divider is closer to that value. That means that you can not detect (at the moment) multiple buttons.

Future My purpose is to add some extra features. But I will add them as soon as I have the need.

  1. Duration of the press, detectable at onButtonRelease event. This event will be backword compatible.
  2. Timeout value and event. In case of LCDs you may need to do something but after a specified amount of seconds your sketch must go back to the default LCD layout. So
  3. A new property timeout_seconds will be added to main object.
  4. A new event onTimeout(int seconds) will be fired at your sketch when your last keypress happened more than timeout_seconds ago.

Installation

  1. Create a folder under \libraries named CDButton
  2. Copy the contents of the zip file into the above folder

Schema for connections

// 5V -----[Button]-------- [Resistor] ----------------- ANALOG PIN --------- [Pulldown Resistor] ------- GROUND // | // 5V -----[Button]-------- [Resistor] ----------------- // | // 5V -----[Button]-------- [Resistor] ----------------- // | // 5V -----[Button]-------- [Resistor] -----------------

each button connects 5V to an analog pin thru a resistor. the analog pin has a pulldown

The library is free for any purpose except criminal actions.

Constantinos Dafalias [email protected]

About

Library for arduino analog buttons

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published