Contributions

Contributions are appreciated and used to host this site. Thank You for your support.

Feature Products
  • Raspberry Pi with Java: Programming the Internet of Things (IoT)
    Raspberry Pi with Java: Programming the Internet of Things (IoT)
  • Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
    Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
  • Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
    Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
  • Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
    Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
  • Getting Started with Raspberry Pi
    Getting Started with Raspberry Pi
  • Raspberry Pi User Guide
    Raspberry Pi User Guide
  • PiBrella LED Add On Board
    PiBrella LED Add On Board
  • Diversitech® WS-1 - Wet Switch Flood Detector
    Diversitech® WS-1 - Wet Switch Flood Detector
  • Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
    Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
  • Floodstop Washing Machine Valve Shutoff Kit
    Floodstop Washing Machine Valve Shutoff Kit
  • Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
    Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
  • Floodstop Individual Water Appliance Additional Water Sensor XS-01
    Floodstop Individual Water Appliance Additional Water Sensor XS-01
  • Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
    Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
  • Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Metra 70-2002 Radio Wiring Harness for Saturn 00-05
    Metra 70-2002 Radio Wiring Harness for Saturn 00-05
  • Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
    Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
Wednesday
Dec052012

Raspberry Pi - John Jay's 8 LED & Button Breakout Board

Overview

In a previous article I demonstrated how to build your own Raspberry Pi GPIO testing board that included buttons, slide switches, and LEDs.  Since that time, I learned about a retired engineer in Georgia named John Jay who is producing awesome little companion electronic boards and kits for the Raspberry Pi.  The boards are available as DIY kits and/or fully assembled boards.   The kits are very reasonably priced and are available now on eBay.  Click here to see John Jay's eBay listings.  One of Mr. Jay's kits is an 8 button / 8 LED GPIO button breakout board.  Using this kit is certainly easier than acquiring all the individual electronic components and building the board on your own.  
I made one slight modification to the kit so that I could connect the breakout board to my Raspberry Pi via a 26 pin ribbon cable. 

Shopping List

Parts for Optional Ribbon Cable & Connector (below)

Tools

Assembly


Assembly instructions can also be found on John's website: http://mypishop.com/Pi%208%20LED%20&%208%20Button.html

The kit includes the following components:

  • 1 @ printed circuit board
  • 8 @ green LEDs
  • 8 @ momentary/normally-open pushbutton micro-switches
  • 2 @ resistor networks
  • 1 @ 26 pin PCB mount female header
    (not pictured)
  • 1 @ peel-and-stick on rubber bumper 
    (not pictured) 

 

 In addition to the parts provided in the kit, I also used a right-angle 26P male box header socket for connecting a 26P ribbon cable to the Raspberry Pi.

 

 


TIP
:  Click any image to enlarge and view a high-resolution photo. 

STEP 1 > Insert the 26P male header socket in the position at the edge of the board and then solder the pins in place on the bottom side of the board.  NOTE:  If you are not using this optional IDC box socket connector and you are using the supplied female header, then be aware that it should be mounted to the bottom of the board and soldered in place on the top.

  

 

STEP 2 > Insert one of the A102J resistor networks into the RP1 position on the top of the board.  Solder in place on the bottom of the board.  You can bend the pins over to help hold the component in place while you solder. 

 

STEP 3 > Insert the second A102J resistor network into the RP3 position on the top of the board.  Solder in place on the bottom of the board.  

 

STEP 4 >  Next we will install the 8 LEDs.  The LEDs have a short lead (cathode) and long lead (anode).  The long lead (anode) should be insterted into the hole closest to the 26 pin header connector.  See the photos below to make sure you have them in the correct orientation. 

 

Insert the 8 LEDs in position and then carefully flip the board and solder each LED in place.  TIP:  You may find it easier to solder just one lead of each of the LEDs and then check the LEDs from the top and adjust any for final positioning.    

After soldering each of the LEDs use a pair of wire snips to trim the excess lead wires. 

 

STEP 5 >  Next we will install the momentary buttons.  Each button has four pins that will insert into the board.  Press each switch in place firmly to fully seat the switch.  


Once the switches are placed, flip the board and solder each of the pins on all the switches. 

 

That's it.  Now you have a complete assembled board ready for use with your Raspberry Pi.  

Logic

The 8 LEDs are controlled by positive 3.3 VDC TTL voltage on each of the corresponding GPIO pins.  Setting a GPIO pin to HIGH will cause the LED to turn ON and setting a GPIO pin to LOW will turn the LED OFF.

When depressing one of the 8 input buttons, the closed circuit will provide a ground drain for the GPIO pin thus causing it to go LOW.  When an input button is not depressed the circuit on the GPIO pin will remain floating; therefore, each of the GPIO pins used with these buttons should be configured to set their internal resistors to pull up.  In software, this means that the button will remain in the HIGH state when it is not pressed and will go LOW while a button is pressed.

LED Wiring Diagram

The 8 LEDs are mapped to the P1 header on the Raspberry Pi as depicted in the diagram below.

Button Wiring Diagram

The 8 buttons are mapped to the P1 header on the Raspberry Pi as depicted in the diagram below.

GPIO Pin Cross-Reference Chart

Below is a cross reference chart to better help define the GPIO pin numbers used for each button and LED.

C Sample Program

If you are interested in native C sample code, please check out this article on Gordon's Project Blog:
https://projects.drogon.net/more-buttons-and-leds/ 

Gordon provides a sample program based on the WiringPi library.

Python Sample Program

The following Python source example was provided by John Scuteri
https://github.com/johnscuteri/OpenSourcedButtonBoardTest/blob/master/MyTestProgram.py

Java Sample Programs using Pi4J

Below is a sample Java program for monitoring the 8 buttons on this board. 

Below is a sample Java program for creating a cylon effect that cycles through the 8 LEDs on this board. 

Final Thoughts

Assembling this kit was simple and takes about 30 minutes.  This kit is a very convient tool to have on hand while testing and developing software for the Raspberry Pi.  This kit is also a very good educational kit to begin interacting with the Raspberry Pi's GPIO pins.  

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (2)

References allow you to track sources for this article, as well as articles that were written in response to this article.

Reader Comments (15)

How do you put the Java code I created a file jjLed8.jar and pasted it in but have no idea how to deal with java

December 25, 2012 | Unregistered CommenterMalakai

@Malakai,

1.) First you have to install a Java Runtime / Development Kit on your Pi. If you are running on Raspian, then just use this command on the terminal:

sudo apt-get install openjdk-7-jdk

2.) Next, since this code depends on the Pi4J project, you must download and install Pi4J. Instructions here: http://pi4j.com/install.html

3.) Next, download once of the source Java files above. In this example we will use the cycle/cylon example. Use this command to download the raw source file and store it to a local file on your Pi from the console:

wget -O CycleGpioExample.java http://pastebin.com/raw.php?i=tVm5Ka66

4.) Next, we need to compile the Java source file. Use this command via the Pi console to compile the Java source file:

javac -classpath .:classes:/opt/pi4j/lib/'*' -d . CycleGpioExample.java

5.) Finally we can execute the Java test program using this command from the Pi's console:

sudo java -classpath .:classes:/opt/pi4j/lib/'*' CycleGpioExample


When you want to terminate the program, press CTRL-C to stop.

That's it :-)

December 26, 2012 | Registered CommenterRobert Savage

Cylops programs works fine, thanks

Trying to use the Listener program but I don`t know if it is working.

How can I check with a browser or SSH terminal?

Sorry for a basic question but i'm a newbie.

January 8, 2013 | Unregistered CommenterWayne

Sorry what get is a message saying file not found but I see it in the examples directory when I try to compile it...see below

pi@raspberrypi ~ $ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . ListenGpioExample.java
javac: file not found: ListenGpioExample.java
Usage: javac <options> <source files>
use -help for a list of possible options

January 8, 2013 | Unregistered CommenterWayne

I'm currently testing this board with my Java code using Pi4J. The outputs all work fine but I'm confused by the inputs, which are not working so well. As I understand it, the buttons pull the pins to ground via a resistor. So the inputs are floating and you need to set the PinPullResistance to OFF. If it was set to PULL_DOWN, then it would already be low.

I've tried both settings and the OFF is the only one that partly works as I'd expect but it doesn't work reliably as the input pins really need a pull up resistor to +V and this isn't present on the board. I'm seeing the odd transient because of this but it doesn't detect button pushed reliably.

If I don't use this board and connect each input pin to pin 1 on the header my code works fine. Am I misunderstanding something?

Rob

January 10, 2013 | Unregistered CommenterRob Collingridge

The Listener program does not work on my board but the cyclon works fine. Has anyone go the program to work?

January 22, 2013 | Unregistered CommenterWayne

@ Wayne,

You can just SSH to your Raspberry Pi and monitor the console output to see the results of the listener test program. Or you can connect the Pi to a HDMI monitor and see the results on screen via the console.

If you are not seeing any input, you may need to update the firmware on your Raspberry Pi. Try using the following two commands to update:

sudo apt-get update
sudo apt-get upgrade

Then reboot the Pi and try the listener test program again.

Thanks, Robert

January 23, 2013 | Registered CommenterRobert Savage

@Rob,

Yes, when you press a button on this board, it completes a circuit between the GPIO pin and GROUND. So this means that we want to see some positive voltage on the GPIO pin when the button is not pressed. The internal PULL UP resistor should be enabled so that the pin has a positive voltage bias when the button is not depressed. Without PULL UP or PULL DOWN enabled, the PIN will be in a floating state and you will see unpredictable results. If PULL DOWN is enabled, you are giving it a bias to ground and will never see any input changes. The PULL UP resistor provides a weak positive signal on the pin and when the button is pressed the pin drains to ground. Thus the software reading the pin will see the pin in a HIGH state when the button is not pressed due to the positive voltage bias and then it will switch to a LOW state when the button is pressed and the pin is drained to ground.

Thanks, Robert

January 23, 2013 | Registered CommenterRobert Savage

Thanks so much for posting this. It has been quite useful. Has anyone tried out John Jay's 32-bit "Protect My Pi" board? That's my next project. If there are already java samples floating around, I haven't found them and would love a pointer.

March 25, 2013 | Unregistered Commenterwkrp28

Sorry for responding to my own comment, but I just found MCP23017GpioProvider.java in Pi4J and the example MCP23017GpioExample.java. These are a great start. Let me change my question. Before using this do I need to un-blacklist i2c in raspi-blacklist.conf and load the i2c module via /etc/modules?

Thanks,
Joe

March 25, 2013 | Unregistered Commenterwkrp28

@Joe,

Glad you found the MCP2317 provider. There is also a simple example Java program available here that implements the provider:
https://github.com/Pi4J/pi4j/blob/master/pi4j-example/src/main/java/MCP23017GpioExample.java

I have been meaning to write up an article on the assembly and usage of the Protect-My-Pi board, but have not gotten around to it yet. Yes, you will need to un-blacklist the i2c kernel driver and reboot. I think that is all you have to do --- its been a while since I set this up.

Thanks, Robert

March 25, 2013 | Registered CommenterRobert Savage

@Robert,

Thank you for the tips. I'll try it out and let you know when I get it working.

Joe

March 25, 2013 | Unregistered Commenterwkrp28

I bought the board for a project. I wanted to work with Python as that is what is recommended for the Raspberry Pi and I would then be forced to learn a new language. I had problems with the RPI.GPIO and found RPIO to be a better tool set to work with as it allows the resistor value changing. I made my own tester program in Python inspired by your button tester program and incorporating the LEDs. I felt linking my Git here might help future viewers of this site if they preferred to program in Python. The following is a link to my Git


https://github.com/johnscuteri/OpenSourcedButtonBoardTest/blob/master/MyTestProgram.py

September 18, 2013 | Unregistered CommenterJohn

@John,

Thanks for the link. I'll include it up in the main article body as well.

Thanks, Robert

September 29, 2013 | Registered CommenterRobert Savage

I'm 70 and have many years of computers under my belt. This week I built the LED board and I'm trying to test it with the Python program you supplied . I'm a newby at RPI and Linux and Python.

Your program couldn't find "RPIO"

After some reading on the web, I ran the following command successfully:

sudo apt-get update
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio

As your program again failed to find RPIO, I did some more research on the web and then issued the following command:

sudo apt-get install RPi.GPIO.RPIO

with the following result:

Reading packagel lists.... Done
Building dependency tree.... Done
Reading state information... Done
E: Unable to locate package RPi.GPIO.RPIO
E: Couldn't find package by regex "RPi.GPIO.RPIO'

Can you help please?
Thanks.

January 16, 2014 | Unregistered CommenterCo Termors

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
« Twine - Garage Door Monitor (Revisit) | Main | Raspberry Pi - Sunrise / Sunset Timer for Christmas Lights »