Controlling LEDs With The Ciseco Slice of Pi/O – Part 3

Controlling LEDs With The Ciseco Slice Of Pi/O – Part 3An army of LEDs!

In Part 1 I showed you how to set up a Slice of Pi/O add on board for the Raspberry Pi, which we then tested in Part 2 by getting an LED to light up using one of the additional outputs the board supplies.

In Part 3, I’ll show you the Slice of Pi/O being used to its full potential – using all 16 outputs to drive LEDs as a prototype for my sports scoreboard project.

What you will need:
    • 1 x large breadboard (830-point or similar)
    • 16 x LEDs
    • 16 x resistors for the LEDs
    • 1 x 10k resistor for the switch
    • 1 x 4-pin header (optional)
    • 2 x 8-pin headers (optional)
    • 1 x Tactile switch
    • 20 x male-to-male jumper wires

Check out Part 2 if you want to use the same items that I use here.

Before we start

As always, turn off your Pi (you can use sudo halt from Terminal, or just do it the GUI way)

Solder the headers

If you want to solder your power and GPIO jumpers directly to the Slice of Pi/O, then technically you can skip this step. However, I like to add the headers to the breakout holes of my Slice of Pi/O to make prototyping easier.

I’ll use the 4-pin header as an example. Your 4-pin header should look like this:

4-pin header

4-pin header

 And here is where it goes on your Slice of Pi/O: 
 
Front
Slice of PiO header points

Enter the 4-pin header here

 Back
Slice of PiO soldering

View from the back

Pop the header through the holes and solder away (best find a soldering blog if you want to learn how to solder):
Slice of PiO soldering 4-pin headers

Soldering the 4-pin header

 
NOTE: I also soldered the GPIO holes into headers too – same method:
Slice of PiO GPIO

GPIO headers added as well

Connect the parts
 
Now that your Slice of Pi/O’s header is soldered, it’s time to dive right in and connect all of the parts together.
 
I could take 20 pictures and try and explain it piece by piece, but this time I think a well annotated video may the better way to do it. The video quality isn’t great but the text should help you along:
 

All we have done here is:

  • Link up the PWR and GND pins to the breadboard power lanes
  • Added 16 LEDs to the centre split on the board (positive leg upwards)
  • Linked the positive LED legs to each MCP23017 output in order
  • Linked the negative LED legs to the GND supply with a suitable resistor in line
  • Added a tactile switch linked to GPIO 25 to act as our ‘goal’ button
All parts connected
Raspberry Pi scoreboard project

What it should look like

 
By watching the video, paying attention to the video comments and looking at the pictures in this blog, you shouldn’t have any problems putting this together. If you do, drop me a comment and I’ll add more detail.

The Python code

As I’m still in the prototype stage, this code isn’t the full scoreboard experience – not even close. The end result will have 2 different score lanes and sets of buttons for each team, with ‘minus’ goal buttons in case of mistakes. I may also add power-play indicator LEDs, a timer and other features.
 
What this code does do is confirm all 16 outputs work, the button to register a new goal works, and that we can make some kind of order to the lights so that it will act like a scoreboard. It’s a great starting point, and the code doesn’t need to get too complex.
On each button press, my code will light