General Purpose Debouncer

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

General Purpose Debouncer

Postby miscjunk » Tue Apr 24, 2012 3:05 pm

I bought the I2C LCD Shield kit, and needed to debounce the pins. Existing debounce code is based on reading inputs from pins ... I realized it would be useful to be able to 'debounce' any boolean variable, and thus created GeneralDebouncer library.

What does it need?

1. A function to return the current unbounced input that looks like this:
bool getRawInput(int buttonIndex);

2. Call update(); whenever you want to sample the buttons.

What does it give you?

It tells you the state of each button:
BUTTON_STATE_PRESSED: Button pressed
BUTTON_STATE_RELEASED: Button released
BUTTON_STATE_PRESSED_FROM_RELEASED: Button 'just' pressed
BUTTON_STATE_RELEASED_FROM_PRESSED: Button 'just' released
BUTTON_STATE_INVALID: Invalid button requested
Attachments
GeneralDebouncer.h
(835 Bytes) Downloaded 35 times
GeneralDebouncer.cpp
(2.64 KiB) Downloaded 44 times
miscjunk
 
Posts: 1
Joined: Tue Apr 24, 2012 1:55 pm

Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 3 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]