C.L.A.S. LED board for B+ Pi

So you’ve got a Customisable LEDs And Switches (C.L.A.S.) board for the new B+ model of the Raspberry Pi?! It’s an easy to build, easy to program little kit with a few features that you won’t find on some other similar boards… read on to find out how to solder the kit together and then how to program it!

But first, why is it called customisable? Have a look at the photo below and you’ll see two of the many ways the C.L.A.S. board can be configured. On the left is the basic version and in the middle is a variant where three of the four ‘slots’ are being used to hold push buttons rather than LEDs:


Soldering the C.L.A.S.

Building the C.L.A.S. is easy! We’ll look first at how you solder the basic version of the kit and then talk a bit about how you could solder the customisable version.

Hint: some people may find it easier to solder the GPIO connector in place first.

1) I started by soldering the resistors in place: these may be smaller to resistors you’ve soldered in the past, but don’t go hunting for your magnifiying glass, there’s no need to read the colour-code bands as they’re all the same value.

2) Next I soldered the push button in the top ‘slot’ (next to where it says ‘B+’ on the PCB). The button has a rectangular [not square] footprint so will needs to be fitted the correct way round and may need a little pressure to get it to sit flat against the PCB. Note that the C.L.A.S. kit may be posted to you with the push button already fitted in place to reduce the risk of its legs getting bent in the post. You will still need to solder it, though.


3) The remaining three ‘slots’ hold the LEDs with red next to the push button, then yellow, then green. Make sure you insert the longer of the LEDs two wires into the hole marked with a ‘+’ symbol (also, the pad for the long wire is square shaped). Hint:to avoid ‘wonky’ LEDs, you can use a piece of tape to hold it in place whilst you turn the board over to solder. Just solder one wire initially then turn the board over to check the LED isn’t wonky: if it is wonky, trim the wire and get your solder sucker out and try again!


4) You can now solder the GPIO connector in place, noting that it goes on the opposite side of the PCB to all the other components. If you’ve got version 0.1 of the C.L.A.S. (as shown here) then note that a pair of pins has been removed from each end so that there are only 36 pins to solder instead of 40 (I could explain why but, frankly, it’s not very interesting and later versions won’t have this quirk!). It’s tricky to get the connector at a perfect right-angle to the board but a blob of Blu-Tak may help hold it in place whilst you solder. It’s a good idea to solder just one pin and then check for wonkiness before proceeding: if necessary, you can then press on the GPIO connector whilst you melt the solder joint you just made and the GPIO connector should fall into place neatly against the PCB.

Soldering the Customisable Version

In the customisable version there are 4 LEDs and 4 push buttons for you to use as you wish: each ‘slot’ can hold either a push button or an LED. However, the resistors and the GPIO connector are exactly the same as above. Note that, currently, there are no code examples for customisable versions of the C.L.A.S. board, but you could look at the code for the basic version for inspiration.

Programming the C.L.A.S.

Once you’ve built the basic version of the C.L.A.S. kit, mount it on your Raspberry Pi PCB like this:


You’ll now need some code to do something interesting with the LEDs. Here is a bit of python code that you can copy and paste into a file called basic.py and then run by typing sudo python basic.py

# flash LEDs in sequence on the CLAS board for B+

import RPi.GPIO as GPIO
import time


# GPIO allocations
button = 22
red = 10
yellow = 11
green = 5

# set the LED pins as outputs...
GPIO.setup(red, GPIO.OUT)
GPIO.setup(yellow, GPIO.OUT)
GPIO.setup(green, GPIO.OUT)
# ...and the button as an input (note: the button
# requires use of the Pi's internal pull-up resistor)
GPIO.setup(button, GPIO.IN, pull_up_down = GPIO.PUD_UP)

def check_button_and_pause():
  if (GPIO.input(button)):
    # button NOT pressed
    # button IS pressed

for i in range(10):
  GPIO.output(red, 1) # red on
  GPIO.output(red, 0) # red off

  GPIO.output(yellow, 1) # yellow on
  GPIO.output(yellow, 0) # yellow off

  GPIO.output(green, 1) # green on
  GPIO.output(green, 0) # green off