Thanks to Adafruit forums user jackv for sharing this great Instructables tutorial with us!
If you ever find yourself running out of GPIO pins on a RaspberryPi you can put multiple pushbutton switches on a single pin using this method. It sets a variable by timing the charging of a capacitor through a series of resistors with the switches between them.
You will need a RaspberryPi, a breadboard, and a way to run wires from the RaspberryPi to the breadboard. You can use male/female jumper wires but one of the Pi Cobblers listed on this page from Adafruit will make it a lot easier: http://www.adafruit.com/search?q=cobbler
You will also need:
- 0.1uF ceramic capacitor http://www.adafruit.com/product/753
- 6 22K resistors *
- 22 gauge hookup wire
* This is a very handy assortment of resistors https://www.sparkfun.com/products/10969
This project uses the wiringPi libraries, written by Gordon Henderson, for programming the GPIO in C in a style similar to the Arduino IDE.
wiringPi must be installed.
Instructions for download, install and use are located at http://wiringpi.com
wiringPi uses it’s own pin numbering scheme. All pin numbers mentioned in the program or in the text are wiringPi numbers unless otherwise specified.
After installing wiringPi you can obtain a list showing the pin numbering for your specific model of RaspberryPi by opening a command terminal and typing:
gpio readall
Featured Adafruit Products!
Adafruit Assembled Pi T-Cobbler Breakout for Raspberry Pi: Now that you’ve finally got your hands on a Raspberry Pi® , you’re probably itching to make some fun embedded computer projects with it. What you need is an assembled add on prototyping Pi T-Cobbler from Adafruit, which can break out all those tasty power, GPIO, I2C and SPI pins from the 26 pin header onto a solderless breadboard. This mini kit will make “cobbling together” prototypes with the Pi super easy. Designed for Raspberry Pi Model B Revision 1 or Revision 2. Designed for use with Raspberry Pi Model B AND Model A, both revisions. This will not work with the Raspberry Pi 2 or Model A+ or B+ If you have one of those, check out our 40-pin version of this item. Read more.
0.1uF ceramic capacitors – 10 pack: As any engineer will tell you, 0.1uF ceramic capacitors are the magic fairy dust of electronics – sprinkle them over your circuit schematics for good luck! But seriously, a 0.1uF capacitor right next to the VCC pin of your chips will improve stability by filtering out power supply spikes and noise that can cause flaky behavior. We love these little guys, they have 0.1″ spacing so fit into any perf or breadboard, compact and good quality. We use these exclusively in all our kits, and are always handy for any project or prototype! So useful, we offer them in packs of 10. Read more.
Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!