I recently came up with a way to read the state of 6 push buttons using only three I/O pins and wanted to share it. You may find this especially interesting for pin-limited boards, such as the Gemma and Trinket. My idea may have been invented before but, so far, I've not found a reference that describes the same technique, so I've shamelessly named it WaynePlexing after the Charlieplexing (http://en.wikipedia.org/wiki/Charlieplexing) method often used with LEDs. To see how my idea works, see my writeup at:
https://sites.google.com/site/waynehold ... ng-buttons
Or, if you have seen this technique used before, please leave a comment and dash all my dreams of short-lived fame and glory.
Wayne
Read 6 Push Buttons using only 3 I/O pins (and no other part
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- wholder
- Posts: 59
- Joined: Mon Mar 16, 2009 2:09 pm
- lburnham
- Posts: 23
- Joined: Wed Jul 16, 2014 10:56 am
Re: Read 6 Push Buttons using only 3 I/O pins (and no other
Can pin d1 be used as an input on the gemma?
- lburnham
- Posts: 23
- Joined: Wed Jul 16, 2014 10:56 am
Re: Read 6 Push Buttons using only 3 I/O pins (and no other
"All the GPIO pins can be used as digital inputs, digital outputs, for LEDs, buttons and switches etc"
Just noticed this.
Just noticed this.
- SeiRruf
- Posts: 82
- Joined: Thu Sep 04, 2014 3:07 am
Re: Read 6 Push Buttons using only 3 I/O pins (and no other
This is a very excellent, awesome idea for those who absolutely need more buttons but have limited pins. I think I'd personally rather stick with the Analog approach, where you can hook a number of buttons using only one pin and a few resistors. But this is definitely something to keep in mind.
One thing though, I noticed for this to work, you have to short pins to each other. Without a 10K resistor in between the circuit, wouldn't this eventually if not right away damage the arduino? Speaking from this reference schematic (below)
Cited from: ruggedcircuits.com/10-ways-to-destroy-an-arduino
Just something I'm pondering on.
One thing though, I noticed for this to work, you have to short pins to each other. Without a 10K resistor in between the circuit, wouldn't this eventually if not right away damage the arduino? Speaking from this reference schematic (below)
Cited from: ruggedcircuits.com/10-ways-to-destroy-an-arduino
Just something I'm pondering on.
- wholder
- Posts: 59
- Joined: Mon Mar 16, 2009 2:09 pm
Re: Read 6 Push Buttons using only 3 I/O pins (and no other
Thanks for the reply. No resistor is needed and there is no danger of shorting two pins as long as the programming is handled correctly. The trick that makes this work is the AVR family's ability to switch the pin's function as Input vs Output independently from its state (High vs Low.) The code flips these in a particular order (see my article) to prevent a pin from ever being set as an output in the high state. At any given time, a pin can be an Input with the pull up resistor engaged, or an output that's in the Low state.
Wayne
Wayne
Please be positive and constructive with your questions and comments.