The Raspberry Pi has an internal pull-up resistor associated with most of its GPIO pins. These are reknowned as rather weak (~50 k ohms), and so the Pi people suggest that you add your own. I have done so in the graphic shown in figure 1.
The leads diverging from the bottom of the PCB, are ten in total: 4 (each) ended in individual female headers, for the Cirrus/Pi2 stack attachment (GPIO) – and 4 (each) ended in individual male headers, for the membrane switch attachment (that pretty little stoplight membrane that adorns the face of the homemade tablet). Then there’s one 3.3V power lead, and one GND lead, each ended in female single header connectors for connection to the expansion header on the Cirrus audio card, which feeds 6 GPIO through from the Pi2. Not sure what I’ll do when I need more GPIO pins than that.
Next, I downloaded the WiringPi software kit, to interface (programming perspective) to the GPIO:
- git clone git://git.drogon.net/wiringPi
- cd wiringPi
- gpio -v
- gpio readall
The value of the pull-ups is a matter of debate. It depends (I’d suppose) on the ultmate function of the GPIO, and the characteristics of that to which it connects. For simple switches such as the membrane switch I’m using, I’ve seen people using various values from 1.8k ohms to 4.7k ohms. I chose the latter, since it would consume less power from the Pi2 board. The Pi2 board only has around 16 mA (or so I read) maximum GPIO current capability.
The membrane switch pad I chose has closed contact resistance of 25 ohms. The voltage divider that creates will allow the GPIO to be seen as low logic (I hope) – since I’m using pull-up resistors that I will pull DOWN with the membrane pad. Confused yet?
Since I love to scribble in Gimp so much, I’ll make a little sketch in a while. A picture always explains this stuff better than words.
So, the idea is that the membrane connects the junction at the bottom of the pull-up board to GND, and drives the GPIO pin LOW. The line on the far right of the ribbon in the graphic is the “common” – and is connected to GND. the four lines on the left of the ribbon cable are the individual membrane switch lines. The zener helps with transients (theoretically). This GIMP drawing is not my best. Wow – is that one UGLY resistor. Sometimes it IS a better idea to pull out the regular schematic application :-(.
The little pull-up board was mounted near the Pi2, so as to make the wires shorter. It was mounted vertically, in that space between the enclosure’s connecting posts. Then, I made the first test of the membrane pad, using the wiringPi gpio command to read all GPIO at once:
So, all in a day’s work, we say.
Note: This author and site is not affiliated with the Raspberry Pi in any way. For information about those projects visit http://www.raspberrypi.org. “Raspberry Pi” is a trademark of the Raspberry Pi Foundation. Also, the wiringPi project is distributed via a free software license. If these screenshots are “derivative” works, then they falls under the same license as the program itself, the GNU GPL license version 3. The Cirrus audio adapter is distributed by Cirrus Logic, which has no connection whatsoever to this site. Figures 3, 4, and 5 contain elements of a desktop system and associated programs that have been released under a free software license (Copyright: LXDE team: http://lxde.org). As a derivative work of that program, the respective part of the screenshot falls under that same license. The full text of the licences (GPL 2.0+ and LGPL 2.1+) may be found at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html and http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.