They’re Chickens!

So, as anyone who has kept chickens will tell you, Aardman Animations Chicken Run is a documentary…

Chickens escape. Or try very hard to…

We’ve kept chickens before, but after a year off, decided to get some more and within an hour of getting them home, one had escaped from the pen and (literally) jumped over the wall into the abyss beyond. Fortunately (amazingly!) it developed the power of flight and managed to fly up the 3m wall on the other side (another 3m away!) and ended up in our neighbours garden. Which is just as well as the local abyss is a river which is running rather rapidly right now!

The grass is always greener, eh?

(And for those who don’t know – chickens sink, so she was lucky that time)

chickensOur chickens. They are (from left to right), a Speckledy Maran, a Colombian Black Tail and a Blue Maran.

I wasn’t keen on giving them names, however they have come to be known as:

gingerGinger – the escape artist

edith2Edith II

 (Looks like another Speckledy Maran we had called Edith)

dbThe Drug Baron

(Because she’s a Colombian Black Tail)

One egg so-far – but we did expect that as we were told the Marans were either laying or ready to lay imminently.

eggNot 100% sure which chicken, but I suspect it’s Edith II that’s laying so-far.

We got them from Paul and Jill at Harepathstead Poultry in West Devon who are a family run business specialising in supply, breeding and rearing of commercial and rare breed chickens and bantams. This is the second time we’ve bought chickens from them. (But if you do decide to visit them, take wellies! East Devon is a bit soggy underfoot right now!)

And tonight we clip their wings. (Well, the primary flight feathers off one wing if you want to know the technical details – not their actual wings!)

So there you are. Maybe something a bit different from computer projects, but I’ll put this one in the cooking category!

Quick2Wire – Boards are here!

The Quick2Wire project has been in the process of designing some new interface boards for the Raspberry Pi for some time and now they have some hardware!

I got a kit from them recently comprising the main board and the GPIO expander board – soldered it up without too much difficulty and here it is:

Quick2Wire board and GPIO expander

Quick2Wire board and GPIO expander

The main board connects to the Raspberry Pi with a standard 26-way ribbon cable. To the left and right of the main board are expansion sockets for SPI devices and at the bottom is an 8-way GPIO connector and the I2C connector. I2C boards can be connected in series, so the board I have here has a 2nd I2C connector for the next board along.

On the main board, there is an 8-way connector for the Pi’s own GPIO connections. This is protected by resistors and zenier diodes in the same way as Mike Cooks Pi Breakout Board. This means that you can connect it directly to LEDs without any series protection resistors and that it’s also tolerant of 5v (or maybe more) going into the board accidentally.

The main board has a 3.3v voltage regulator which is passed to the peripheral boards. This takes the load off the Pi’s own 3.3v supply.

It also features an LED and a button – these are connected to pins 1 and 0 respectively, but via little jumpers, so if you need to use those pins for other uses, then you can.

Finally, on the main board there is a buffered serial port connected to the Pi’s on-board UART. This will drive standard 5v TTL type devices and be safe when driven by them too.

Using the board is very easy – the 8 GPIO pins are numbered 0 to 7 and use the same pin numbering scheme as wiringPi (And as I understand it, Quick2Wires own Python libraries use this numbering scheme too)

I used the gpio command in wiringPi to give it a test and didn’t have any issues.


gpio mode 0 in
gpio mode 1 pwm
gpio read 0 # Read the button
gpio pwm 1 500 # On-board LED to half brightness.

# Simple LED blink
gpio mode 1 out # Normal output
while true; do gpio write 1 1 ; sleep 0.5 ; gpio write 1 0 ; sleep 0.5; done

Taking advantage of the on-board resistors, I connected an LED directly between pin 2 on the mainboard and 0v, and

gpio mode 2 out
gpio write 2 1

and it lit up, as expected.

The I2C expansion board was easy too – I used gpio to load the I2C modules into the kernel (which then allows the user to access them without sudo, then the standard i2cdetect to probe the bus:

gpio load i2c
i2cdetect -y 1 # Rev. 2 Raspberry Pi, I2C device 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

Device 0x20 is the I2C code for the MCP23017 GPIO expander chip, so it was detected correctly. The expansion board has a set of switches which allow for it to be set to 8 different addresses, (0x20 through 0x27) so it’s possible to have up to 8 of these boards connected if required!

A quick little program later in C, using my new wiringPi I2C helper functions and it’s working just fine:

Quick2Wire I2C Expander in use

Quick2Wire I2C Expander in use

I’ve temporarily put the program here: but will likely be moving it and writing something to integrate the Q2W boards better into wiringPi.

So, a nice little main board with easy to add expansion boards using SPI, I2C and the Pi’s on-board GPIO.

Update on the Raspberry Ladder Board

Tandy now has new stock, so should be properly caught up with the backlog in the next day or two…

I’d just like to say a big thanks to everyone who’s bought one! It’s been a fun little project and my hope is that it’s an easy way to introduce people into simple soldering and computer interfacing too.

There is an update to the Ladder board software I’ve put together – just a little bug-fix for the test program – in my haste to make it a little more modular, I created a separate setup script for bash scripts, and somehow got the button numbers wrong – doh! So I’ve fixed that now. Just do the following to get the updated software:

cd ladder
git pull origin

and off you go. (and as if by magic the green LEDs ought to work with the button next to it now)

I actually fixed this some time back and thought I’d pushed the new version out, but obviously not!

Anything else? Well there has been some people writing programs in Python and Scratch to access the board which is good, and a note from zcat in New Zealand to say that their traffic lights work differently to those in the UK. He says:

Ours go green / yellow / red, green man, red man flashing, then red man solid and directly red to green for traffic.

So there you are! I’m sure (and I know!) that pedestrian crossings work in different ways in different countries, so do let me know what the differences are… Perhaps one day we can have a version that works out your country and does the right thing!

4D Systems Intelligent Displays and the Raspberry Pi

I’ve been doing some work recently with 4D Systems who’re based in Australia and who design some really cool LCD and oLED touchscreen display modules.

The displays themselves have an on-board graphics processor that is designed to take the load off the host processor and gives you a high-level command set to enable you to interact with the display in a very easy to use fashion.

And recently they have introduced a range of displays and an adapter for the Raspberry Pi.

4D Systems Display

4D Systems Display

The photo shows one of their displays (The uLCD 32PTU) with the Raspberry Pi serial adapter.

The adapter board just breaks-out the serial port and the power for the display itself. It leaves all the other GPIO pins available for you own use.

The intelligent part inside the displays comes from the software you use to setup the displays in the first instance – in that picture above, the buttons and sliders were not drawn by the Pi, but are created using a GUI development system called Visi-Genie. This runs under the 4D Systems “Workdshop4” package. You design the display using high-level constructs – build the software that runs on the display – this involves copying data to a Micro-SD card on the display itself, then connect the display to the host computer.

Workshop4 runs under MS Windows, but once programmed the display can connect to any suitable host with the right adapter.

So the process involves designing the display, then connecting it to the host and writing some software to run on the host to interact with the display… And that’s what I’ve been doing – I’ve produced a handy library to help you use the dsiplay from C/C++ programs (it should be easy to use from other languages too – e.g. Python).

At its simplest, you periodically poll the display, and get back a structure containing a message from it. The message might contain information such as “Button 5 pressed”, “Slider 3 moved to position 24”, “Key ‘a’ pressed on keyboard 2”, and so on, or you can send a message to the display: “Set meter 3 to 25”, “Move slider 1 to 0”, etc. The display handles all the animations of the buttons, sliders, gauges, dials and so-on leaving your program to get on with (hopefully!) more important things.

Using this system I was able to write a program on the Pi to have an on-screen slider control the brightness of an LED using a slider on the screen in just a few moments with only a few lines of code.

Have a look at this video to see how it all goes together (and I suggest you pick HD and full screen!)

I’ll be writing more on these displays as I get to grips with them, so keep watching!

CESIL controlled Xmas tree on the Raspberry Pi

CESIL? What on earth is that, I hear you cry! Or maybe some of you are recoiling back in horror at the name of the 1970’s educational programming language stirring up bad memories…

Or you’ve read this months MagPi magazine and seen the article there!

Recent years have seen a resurgence in various activities to resurrect or re-create some of the very first computers that were built. The National Museum of Computing on the Benchley Park estate is home to many projects – and recent additions have been “Colossus” which was designed to break the Lorenz cipher and started working in 1943-1944, and the WITCH computer which came online in 1951 and was recently rebuilt and “rebooted” using most of the original parts in November 2012.

CESIL stands for: Computer Education in Schools Instructional Language. It was a simplified assembly language which students would write out on special coding sheets, then send off to their local computing centre and (hopefully!) get back the results of the run a week later – in time to fix any errors and wait another week…

So fast-forward 40 years or so and lets have some fun with CESIL, a few extensions to the language and a CESIL fairy-light controlled Xmas tree…

CESIL Operators or Instructions
Instruction Purpose
LOAD Transfer the number into the accumulator
STORE Transfer the accumulator into a named variable
JUMP Jump to the given label
JINEG Jump if the accumulator is negative
JIZERO Jump if the accumulator is zero
ADD Add a value
SUB Subtract
MUL Multiply
DIV Divide
HALT End program
IN Read a number from the keyboard
OUT Outputs the accumulator as a number
PRINT Prints a literal string (in “quotes”)
LINE Prints a new line
JSR Jump to a Subroutine
RET Return from Subroutine
Tree Specifics
TREE Create the tree!
ROW Transfer the accumulator into the Row register
COL Transfer the accumulator into the Column Register
COLOUR Set the fairy light indicated by the Row and Column registers to the colour held in the accumulator
WAIT Pause for the given number of centiseconds – Also causes a display update.

A CESIL program is essentially three columns of text. The first column (which  can be blank) is the label – it’s a placeholder in the program which you can “jump” to from other parts of the program. The middle column is the operator – that’s the instruction to execute, and the final column is the operand – this is data for the instruction to use. This data may be the name of a label if it’s a jump  instruction, it may be a number or it may refer to a named memory store, or variable.

The CESIL machine has one register or accumulator. This implementation is limited to a maximum of 256 program lines and 256 variables.

My extensions to the CESIL machine have included 2 more registers to hold the row and column locations of the lamps and a colour instruction to set the lamp colour as well as a subroutine facility.

As an example: here is a simple CESIL program to print out a multiplication table:

# mtable:
#       Multiplication table generator

        print   "Multiplication table generator"
        print   "What table"
        store   table

        load    1
        store   index

        load    index
        print   " TIMES "
        load    table
        print   " = "

        mul     index


        load    index
        add     1
        store   index
        sub     11
        jineg   loop

But maths is boring… So lets play with the xmas tree instead. Here is a picture of our tree with the bottom row of 8 lights red and the rest silver:

The CESIL powered xmas tree

This program makes all the fairy lights silver:

# silver:
#       Make the tree silver!
#       Note: We have 4 rows of 8 columns and
#       Row 0 is the bottom, column 0 is to the left

# Fire up the tree

        load    7       # code for silver
        store   colour

        load    3       # 3 into the Acc
        store   row-count
        jsr     fill-row
        load    row-count
        sub     1
        jineg   done
        jump    loop

done:   halt

# fill-row:
#       8 columns in each of the 4 rows

        load    7
        store   col-count
        load    colour
        load    col-count
        sub     1
        jineg   fill-done
        jump    fill-loop

Fairy Light Colours
0 Black (Off) 8 Grey
1 Navy Blue 9 Blue
2 Green 10 Lime
3 Teal 11 Aqua
4 Maroon 12 Red
5 Purple 13 Pink
6 Olive 14 Yellow
7 Silver 15 White

Get the software

This CESIL interpreter is written in RTB (Return to BASIC), so the first thing you need to do is install the RTB interpreter if you don’t have it already.

Fetch the CESIL code and examples using GIT:

git clone git://
cd cesil
rtb cesil

and off you go. Check the files in the cesil directory – you’ll find several examples including the multiplication table generator (mult), a prime number generator (primes) and a few other examples (all with filename extension .csl) the row-up.csl program contains some handy subroutines for filling the entire tree or one row or one column with a single colour…

You can stop any running CESIL program with the Q key on the keyboard, and pause it with the spacebar.

CESIL programs can be written using any text editor (e.g. nano, vim, etc.) and you can type in upper or lower case – they get translated to upper-case at load time. Filenames should have a .csl extension to them, but you don’t need to type that when loading a CESIL program into the interpreter.

And during December and January 2012, there is a little fun competition running to win one of my Raspberry Ladder boards – but to find out more about that, you’ll need to go and read the MagPi magazine article, or just email me ( with your programs by the 25th of January, 2013 and I’ll make the selection by the end of January.

The Raspberry Ladder Board – Part 2

Last month I wrote about the Raspberry Ladder Board and it appeared in the MagPi magazine too! This month I’ll finish it off with a full board description and some more software.

(And if you don’t have one yet, then get yourself over to Tandy and get one 😉

Firstly, please update the software by running the commands:

cd ladder
git pull origin

or if you are starting from scratch:

git clone git://

which will pull all the software.

The new programs are a “cylon” LED sequencer written in both BASIC and C – the BASIC version will display a copy of the ladder board on the screen.  reaction – another program to test your reaction time, and simon, a “Simon Says” game where the computer generates a sequence of lights and you need to copy them using the buttons with the sequence getting longer and longer…

There are also library template files for C, Bash and BASIC to help you get going with your own programs – see ladderSetup.c, and ladderSetup.rtb respectively. There is a Makefile too which will generate the C programs – the original Ladder game program and the Cylon LED sequencer.

The BASIC version of cylon also creates  a “mimic” display on the Pi’s screen too.

Do read the programs to see what they do, and please change them and write your own!

All the knowledge about the GPIO pin numbers for the LEDs and buttons in contained in the setup files mentioned above, or refer to the quick table below: (The wPi pin numbers are wiringPi pin numbers and will work on either a Rev 1 Pi or a Rev 2, if using the native BCM_GPIO numbers, then be aware that some of them changed from Rev 1 to Rev 2).

BCM Pin wPi Pin LED Button wPi Pin BCM Pin
17 0 Red D/4 13 9
18 1 Red
21/27 2 Yellow C/3 12 10
22 3 Yellow
23 4 Green B/2 10 8
24 5 Green
25 6 Blue A/1 11 7
4 7 Blue
0/2 8 Green Man
1/3 9 Red Man

You’ll need a copy of my BASIC interpreter to run some of these, fetch it by going here: and following the directions. New examples are welcome to be added into the library at any time, please send your creations to and have fun!

A visit to The National Museum of Computing

Last weekend (Saturday the 2nd to be precise!) I visited The National Museum of Computing (aka TNMoC) which is based in the grounds of Bletchley Park.

This was my 2nd visit and I was especially interested in seeing the newly rebooted WITCH in operation and I wasn’t disappointed!

However, first things first. TNMoC is situated in the grounds of Bletchley Park and as well all know, Bletchley Park is home to the WWII code-breakers where they built the machines that decoded the Enigma, (Bombe), Lorenz (Colossus), and who knows what other ciphers and codes during WWII.

It’s important to note that TNMoC is a separate entity to Bletchley Park! They pay rent to Bletchley Park for the bunkers they occupy. That means you pay separately to get into TNMoC and an entry ticket to one does not give you entry into the other.

Currently (Dec. 2012) it’s £12 to get into Bletchley Park and £5 to get into TNMoC, however a slight confusion is that the Colossus and Tunny galleries are part of TNMoC even though they may appear to be part of Bletchley Park, and if you want to visit these, then there is a £2 surcharge on-top of your Bletchley Park fee – but that’s redeemable against the full price of a ticket into TNMoC (you then just pay £3).

Confused? I was, and so are many others, so to recap:

  • Entry to Bletchley Park to see the Enigma and Bombe displays is £12.
  • Colossus is owned by The Colossus rebuild company and is on long-term loan to TNMoC.
  • Entry to TNMoC is £5.
  • If you want to see the Colossus and Tunny galleries then it’s included in TNMoC entry but it’s a £2 surcharge if you just want to see the Bletchley Park (Enigma and Bombe) exhibits.
  • If you paid the £2 surcharge to see the Colossus, and subsequently want to see TNMoC, you only pay the balance of £3 to get into TNMoC.

There is also a £3 car parking fee on-top of that, but I’m not sure if that just applies to BP or to either BP or TNMoC.

So, back to TNMoC:

The WITCH computer is the oldest running digital computer on the planet and I wanted to see it in operation.

The WITCH control panel

The WITCH control panel

WITCH is the Wolverhampton Instrument for Teaching Computation from Harwell – It is essentially a programmable calculator – reading programs and numbers from 6 tape readers, feeding them through its relays, circuits and decatron tubes and producing results on a connected printer. The design was started in 1949 and it ran its first program in 1951. You can read the full story on the TNMoC website.

So I spent quite some time watching it, listening to it and trying to understand what I could of how it works. One day I’ll write a full-blown simulator for it, but not today…

The rest of TNMoC is still fascinating – as well as some of the older computers – IBM , Marconi, Ferranti, Digital (PDP) and so on, there is also a modern (well to me!) selection of microcomputers – starting with the Apple II, going through other variants – the BBC Micro, Spectrum and many others – right up to modern day organisers and the “smartphones” they’ve all more or less become now.

And something that should have been better/popular, but just didn’t make it…. Won’t tell you what, but the keyboard has an “Oops” key on it! (Ok, I will tell you, it was the PERQ!)

They also have some computers that are not that old (relatively speaking!), but completely unknown to me. Just keep looking and asking and you’ll find something you’ve never seen before, and at the end of the long corridor is the BBC Micro room – anyone who was a teenager in the 1980’s in a school in the UK will immediately recognise them and the bits and pieces connected to them.

Finally there is a little cafe and shop – they do nice hot chocolate and (I have to say) although it’s small and doesn’t do food other than biscuits/cakes, I’d go there any day over the canteen in BP!

However, while I thoroughly enjoyed my visit, it wasn’t without issue – the confusion between BP and TNMoC was one, but also I felt that TNMoC was lacking “something”. I suspect a proper sense of direction, but I know that it’s all staffed by volunteers who do a great job, but …

What I’d like to see is more “hands-on” stuff. I spent some time showing my wife how punched paper tape works – and just happened to use a handy TTY33 to help demonstrate it – however that TTY33 had a “do not touch” sign nearby, but hey, what’s a sign…. However that’s an issue. I feel we need more hands on things like that – there is a room with that lovely smell of warm machine oil, but just lots of what looks like junk lying about. What about a few TTY33’s with working tape punches and readers for kids (young and old!) to play with… Connect one up to a computer running BASIC for that proper authentic time-sharing experience… Get one to run “Eliza” and so on…. Hunt the Wumpus, there’s loads of old stuff like that that might be amusing to some…

So there you go – TNMoC – A great place. Visit it you can!

As for Bletchley Park… It’s fine too, but I’m not sure I’ll visit that part of the grounds again – and especially not the canteen )-: Very disappointing there… Take a packed lunch and get into the cafe at TNMoC for a hot chocolate!

Floods in Buckfastleigh

On the evening of Saturday the 24th of November, 2012 the lower part of Buckfastleigh flooded. Both the Mardle river and Dean burns were full to overflowing – with some rather serious consequences. I originally took a few dozen photos and dumped them here, but I’ve now had time to sort them and take a few photos of the morning after – when the river levels had returned to almost their normal winter levels.

Fortunately the rivers do drain rather well here, however a period of constant and heavy rain (lasting weeks) had essentially filled up Dartmoor which normally acts as a big sponge – and the water had no-where to do but to fill up the rivers.

In Buckfastleigh, Station road was the worst hit, but the shop at the bottom of Fore Street (“Curios”, known to some as “Trevors” DIY although he moved out some years back), the Valiant Soldier and a few houses on Fore Street which backed onto the Mardle were also affected.

Our garden backs onto the Dean Burn and the water was up to the top of the steps we have which lead down into the burn. That’s about 2 meters higher than normal.

If you want to see the original snaps I put up here, please go to: and do get in-touch if you need/want lager ones for insurance, etc. purposes.

This is what I first photographed:This is the view into the little gap in the Dean Burn at the bottom of Fore Street/Eliot Plain. The wall on the left is the bridge leading into Eliot Plain. Curios Shop is to the right. The top photo shows the Dean Burn up to, and over the bottom of the bridge. This is probably part of the cause of the Dean to backup up behind Curious and causing it to flood.

This is looking along Station Road. The water ended up a little higher before it started to receded, but the cars are under enough water to cause problems with their carpets, electricals, etc. and the houses to the left all had water running through them.

This is Station Road Car Park. Cars up to their axles at this end, it’s a little lower and so a little deeper at the other end. The bottom photo is the morning after – mud and lots of unhappy people.

A little hard to tell what that is, but it’s the steps at the bottom of my garden that lead down into the Dean Burn. Normally you can walk down them and stand by the side of the burn, but on that night the water was right up to the top and starting to creep down the path. That’s about a 2m rise.

This is the Dean Burn at the bottom of my garden. In the top photo, it’s almost coming over that wooden bridge (it was splashing over it at one point). Normally it’s just a little stream and we see the river bed, even in winter – unless it’s been raining. That bridge is a good 2m above the water level.

This is the bridge over the Mardle at the bottom of the lane off Fore Street that leads into Dial Court, or the old foundry. The Mardle didn’t drop as quickly as the Dean – there’s still another metre of water to go until it gets to normal levels there.

This is the other side (upstream) of that bridge. There were some local concerns about the stability of the walls on the building opposite – fortunately they held!

This is the bridge over the Mardle on Station Road. I’m standing on the wooden bridge that goes over the Dean Burn from the car park into the Millennium Green here. In summer we hold an annual “duck race” and walk under that bridge without bending over… This is where the Mardle and Dean joins. The water downstream of here was “big” and almost all the green was flooded.

Looking down the steps from Dart Bridge road into the millenium green…

The Mardle (+Dean) flooding into the millenium green (Looking from Dart Bridge Road)

These two shots are over the Dart Bridge Road and show the Mardle (+Dean) up to the level of the wall (and it was over the wall just a few meters downstream of here and flooding into a garden). The steps you can just see the top of in the bottom photo lead down to a grating which is the overflow tunnel for the Dean Burn – there’s at least 2-3 metres more water height here than normal.

The townspeople have been remarkably resilient and for most things are getting back to normal now – although it’s been sad to see peoples possessions out on the street in the past week, waterlogged and ruined. David Cameron PM visited the town on Tuesday too and we had some news coverage – good for the town, lets just hope all the insurance companies quotes and promises, etc. are kept!

RTB – Return to BASIC

At long last (well only 10 months or so!) I’ve released my BASIC to the world!

RTB is a modern BASIC in that you don’t need line numbers and it supports nice looping constructs like while/until with named functions and procedures that support local variables and recursion.

It currently runs on the Raspberry Pi and should run on any modern Linux system – as well as on a Mac and hopefully soon, MS Windows too.

If you’re interested, then find it here

More Buttons and LEDs

John Jay based in Georgia, USA is a retired engineer who’s “gotten the PI bug” and designed some new IO boards for the Raspberry Pi. He’s currently selling them via eBay and I have some here to play with!

(I love new toys!)

So-far he’s designed a simple buttons and LED board, a stepper motor driver (although it’s really a versatile 8-bit output port with a ULN2803 darlington driver) and the third is a 32-bit GPIO extender board

The one I’m looking at today is the the buttons and LEDs board – very similar to my Ladder board, but in some ways much simpler and more down-to earth.

His boards are very small and designed to sit on-top of the Raspberry Pi. Here is the button/LED board next to my Raspberry Ladder board and on top of a Raspberry Pi:

John Jays LED/Button board

John Jays LED/Button board

John Jays board on-top of a Pi
John Jays board on-top of a Pi

The board plugs into the Pi (please do it while your Pi is turned off!) and there is a rubber bumper underneath to stop it wobbling and potentially shorting anything out underneath (a problem I noticed in some other boards – thankfully most people have seen the light now and are supplying these little bumpers on their boards)

The board itself presents no issues when using. John has used the switches with the long buttons which make them easier to use than the low-profiles ones. The board has the standard BCM_GPIO numbers on it – so you need to do some conversions if you are using a Rev. 2 Pi as numbers 0,1 are now 2 & 3, and 21 is now 27.

The (very bright!) LEDs have 330Ω limiting resistors and the switches connect to ground via a 1K resistor, so like my ladder board, it’s important to set the internal pull-up resistors on the Pi to read them reliably. (and the 1K resistors will prevent any damage should the pins be accidentally configured as output)

I wrote this little test program to quickly check the boards functions:

 * jjLed.c:
 *      Test program for John Jays LED and Button board
 *      Gordon Henderson
 * The board is laid out as follows:
 * LEDs:      ( 8) ( 9) ( 7) (11)  (10) (13) (12) (14)
 * Switches:     [16]      [ 0]       [ 1]      [ 2]
 *               [ 3]      [ 4]       [ 5]      [ 6]
 * Numbers here are wiringPi pin numbers and will work on either
 * a Rev1 or Rev2 Raspberry Pi

#include <stdio.h>
#include <wiringPi.h>

static int leds [8]    = {  8,  9,  7, 11, 10, 13, 12, 14 } ;
static int buttons [8] = { 16,  0,  1,  2,  3,  4,  5,  6 } ;

int main ()
  int i ;

  if (wiringPiSetup () < 0)
    fprintf (stderr, "Unable to initialise wiringPi\n") ;
    return 1 ;

  for (i = 0 ; i < 8 ; ++i)
    pinMode (leds    [i], OUTPUT) ;
    pinMode (buttons [i], INPUT) ;
    digitalWrite    (leds    [i], LOW) ;
    pullUpDnControl (buttons [i], PUD_UP) ;

  for (;;)
    for (i = 0 ; i < 8 ; ++i)
      digitalWrite (leds [i], !digitalRead (buttons [i])) ;

I saved this into jjLed.c and compiled with:

gcc -Wall  -ojjLed jjLed.c -lwiringPi

and run with:

sudo ./jjLed

and it worked a treat – pushing the buttons resulted in the corresponding LED being lit up while it was pushed – the top 4 buttons control the left-most 4 LEDs and the bottom 4 buttons control the right-most 4 LEDs.

John has a website which is in the process of being put together right now, (see and is selling these on eBay and for $9.99 it’s not a bad deal at all and a good introduction to the Pi’s GPIO.