The Game of Life

One of the talks at last weeks Raspberry Jamboree was by Amy Mather – 13 years old, talking about her implementation of Conways Game of Life on the Raspberry Pi.


For many reasons – and I think it’s great to see todays young people get enthusiastic by some of this things that I myself got enthusiastic about when I started to learn about computers far too many years ago!

Back then I wrote a program in Applesoft BASIC and patiently watched it do generation after generation… taking about 15-20 seconds per generation too )-: And that was in low-resolution (40×40) graphics. High resolution just wasn’t a consideration unless you had all day to wait. Still faster than doing it on paper though!

So in the past few days when I was testing some GPIO expander chips on the Raspberry Pi for the next release of WiringPi, I was a little stuck for something to test them with – then I remembered, John Jay sent me some MCP23017 expander chips on a board along with a red+green LED matrix board, so it seemed obvious – do the plumbing, use them to test the new version of wiringPi, then implement life on the 8×8 matrix.

life1That’s showing a glider, ready to launch…

So a big thanks to Amy for reminding me that computing needn’t be challenging and sometimes some of those things I did 35 years ago are still relevant (and fun) today! (ie. wasted too much time today on this already!)

Although I have to say, life on an 8×8 matrix is somewhat challenging – (I didn’t quite get a glider and a blinker going at the same time), but in these modern days of huge displays and fast processors it gives me something else to think about!

The Raspberry Jamboree

Alan O’Donohoe is  a man with not only a huge amount of energy, enthusiasm and full of all-round niceness (for a teacher 😉 ) but has been arranging Raspberry Jams since the early days of the Raspberry Pi. Recently he arranged a Raspberry Jamboree and stated this:

On Saturday 9th, I’m organising the first Raspberry Jamboree in Manchester, UK. The principle aim of this event is to allow teachers and educators to discover and share the potential of the Raspberry Pi computer for teaching Computing Science, Design & Technology etc. A secondary aim is to share the ingredients & recipe for an effective Raspberry Jam.  We will have many members of the Raspberry Pi foundation there as well as teachers & educators from across Europe.

Although I’m not directly involved in education (yet!) I attended the event and helped run one of the workshops (PiFace with Andrew Robinson and Mike Cook), and run a 15-minute Q&A session for my own wiringPi project too.

The event sold-out! Over 360 tickets were sold for the day and the place was buzzing with people – and not just teachers/educators but enthusiasts like me who are looking to help make a difference.

From my on point of view, I was able to meet up with lots of people I’ve met online via the forums, IRC, twitter and so on, exchange ideas and thoughts and generally just hang out! Did have some embarrassment by meeting people that know me from the forums, IRC, etc., but who gave me their real names rather than their online handles/aliases – see here for my thoughts on that…

Interesting people I met included Romilly Cocking from Quick2Wire, Chris Roffey from Coding Club, “Grumpy” Mike Cook, the chaps from Ciseco, Andrew Robinson of PiFace fame, and his colleagues/students. Simon Walters @cymplecy and his motley crew who were doing the Robotics talk, and many many others too – brain like a sieve though…

The event was sponsored by CPC who had a Pi Shop on-site and who I know also helped out Simon, Ben and Jason on their robotics presentation too with some hardware they needed.

Mike Cook was showing off some of his projects featured in his new book; Raspberry Pi For Dummies – which should be available soon. (And he’s not really grumpy in real life!)

So what did I get out of it? Well I learned that schools vary considerably in their levels of funding and general knowledge in the IT department – from schools that can buy dozens of iPads to schools that have 3 Raspberry Pi’s and can’t afford £60 for 3 PiFace boards… Also, I found that while some schools have very enthusiastic IT teachers, some simply don’t as “IT” has been nothing more than glorified word-processing for so-long, the very thing that the Raspberry Pi is supposed to address is almost in-danger of not being addressed due to the lack of suitably qualified people to teach IT!

Also from my 15-minute wiringPi session – thanks to all who attended! It was really useful to get your feedback – keep it coming, please email or otherwise contact me with suggestions and ideas. I really appreciate it. Installation seems to be a key issue, so I’ll be looking at providing a .deb package for Raspbian – I know there is already a package available for Arch, but things are changing quite rapidly right now. (Gentoo Linux users generally don’t have issues installing from source, so I’ll not wory too much from that perspective!)

It was quite a long day in the end – there was the obligatory pub and food session afterwards, so it was good to mix with the varied crowds that went out. I did manage to take a few photos, so I’ll just include them below here – see if you can spot yourself 😉

cpcStoreThe CPC Pi Store – very early in the morning before people really started to arrive – it was 5 deep in people through the day!

cpcGameA “Simon”/Memory game made by CPC on their stand. Yes, there’s a Pi with a PiFace on-top in there somewhere!

main1The main presentation room – looking from the back – again I got in early before most people started to arrive, so it’s a bit empty here!

mikeCook1One of Mike Cooks projects for his book…

cisecoA “stack” of Ciseco interface boards for the Pi. The bottom one sits on-top of the Pi, and the rest just plug-in…

main2View from the stage – Prof. Steve Furber waits to give the keynote speech.

class1This is the class/demo room where the 45 minute training and demonstration sessions were held.

main3The main room filling up as Alan gives the introduction.

main4Prof. Steve Furber gives the keynote to a near-full room.

class2This is the main “classroom” starting to fill up for the PiFace demo.

wiringPi-qaThe prople who attended my 15-minute wiringPi Q&A session.

beersAndRob and a “sampler” of the beers that the pub does… Careful – at least one of those is 18% ABV …

pimoroniThis is Paul Beech from Pimoroni. A very generous guy with a cool T shirt. Note the person in the background is the waiter at our table in Pizza Express holding his tip – strange to think of a Model A Raspberry Pi as a form of currency…

pinPinsNow this is interesting for a few reasons – one is that it’s a PiBow case (See Pimoroni!) and also note the GPIO “expansion”. It’s a a short piece of ribbon cable with 2 26-pin sockets on it. It fits over the Pi’s GPIO then fits snugly against the side of the PiBow case, presenting a set of sockets for the Pi’s GPIO – so if you have an investment in male to male jumpers – which you will have if you use Arduinos, then this is a way to use them with the Pi. Of-course the pins are now the other way round, but a simple sticker on the case solved that. This great idea is from Chris Roffey.

Handles or real names?

There has been some discussion recently (and probably for a very long time too) about the use of a handle or alias vs using your real name on forums, blogs, social networks, chat systems and so on…

Way back (20+ years ago) I used to go by a few handles online, but then I decided to start to use my real name – Or something close to it – I’m usually just Gordon, or Drogon (anagram, not that you wouldn’t have guessed!), or gordonDrogon or even my email address, so I’m now firmly in the real-name camp.

I don’t have issues with people using a handle or alias, but when interactive with people online, what I do like to see is a profile type page with hopefully their real name and (sometimes as important if giving advice for purchasing stuff) their location.

I think that putting your name to something gives it weight. It gives you more credibility than just being a somewhat anonymous entity.

I also have a terrible memory for faces, names, etc. )-: and it’s caused me great embarrassment in the past – and recently e.g. 2 nights ago at the Raspberry Pi Jamboree. (although a wee touch of alcohol never helps here either!)

During the Pi Jamboree I met many people – and saw their name tags, but no reference to their handles/aliases on the forums, IRC, etc. which was a great shame as there were one or 2 people I’d really have liked to talk more with, but not knowing who they really were was a real missed opportunity.

So a request: If we meet in real life, please let me know what your online handle or alias is! Write it onto your name badge if it’s at a conference, etc. Put up a profile page somewhere that give a bit more information about you and take more responsibility for what you post.

Raspberry Jamboree

Just a quick plug for the Raspberry Jamboree in Manchester this Saturday! Orginised by the ever energetic Alan O’Donohoe (Teacher &Jambassador)

I’ll be there for the day myself – on a stand with Andrew Robinson of PiFace fame (and it looks like “Grumpy” Mike Cook has been squeezed in there too. I’ve also booked a 15-minute wiringPi Q&A slot in the “CPC Pi Shop”

Please stop by and say hello! I might even have a ladder board or 2 to demo (& sell or even give away 😉 who knows!

4D Systems Display – on Arduino!

Just to show you that I don’t just do Raspberry Pi stuff…

4D system have produced a shield that allows you to connect the Intelligent displays up to the Arduinos serial port, so I’ve ported the Raspberry Pi VisiGeni driver to the Arduino…

There’s  few small limitations on the Arduino, but for the most part the calculator demo program you see running in the Arduino is the same as the one on the Raspberry Pi (it needs to be “Arduinoised” to use the Arduino sketch setup() and loop() mechanisms, but that’s all – there’s also a feature of Arduino that makes for an intereting time printing floating point numbers, but a minor detail here!)

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.