Flotilla and python

Building a light meter with Flotilla

Back in March I got my mega Flotilla treasure chest from Pimoroni. I was very excited to see what could be done with it. The Rockpool graphical interface is coming along nicely and I had some fun with that, but I really wanted to dig into the Python API.

flotilla - 1

Before you go any further check out this link from Pimoroni and this one from their website.

flotilla - 2

I wanted my first project to use both inputs and outputs so I decided to create a light meter which displayed the light level both on the number display and visually through a bar chart on the LED matrix.

flotilla - 5

This project uses the matrix connected to 1, a light sensor to 2 and the number display to 8. I screwed the components onto one of the base plates to keep them still!

flotilla - 6

Using the @pimoroni #flotilla as a light meter @raspberrypifoundation

A video posted by MrUkTechReviews (@uktechreviews) on


An hour of code

At key stage 3 we don't yet teach the programming aspects of the new IT curriculum apart from a couple of lessons using Kodu.

During our curriculum days I was given an opportunity to run a Minecraft programming workshop with half of year 7 and half of year 8. This is a workshop I already run at other schools and events so was excited to see what my students would make of it.

The theme for the day in Science was First Aid so we had a look at building a 3D hospital in Minecraft using a few lines of Python code.

minecraft python

For most of the students (apart from the ones who come to Raspberry Pi club) this was their first experience of writing a text based computer program. Students were given a worksheet with the basic program which they had to type in and then run. This was a challenge for many students who found the task of copy typing accurately very difficult. Once the code was written and the hospital was built students then had an opportunity to tinker with the code to change the dimensions and the materials the hospital was made from.


It was a really interesting experience giving the students "an hour of code". Most of the students engaged with it well and were keen to type in the code and tinker with it. Some became frustrated when their code didn't work and they had to go back and debug it.

Minecraft on the Raspberry Pi is definitely a great way of introducing students to text based programming.

The code for the hospital can be found here.



1000 downloads of 10EPP

1000 downloads.001

We have just had 1000 downloads of 10 Engaging Python Projects. We are so proud that people have downloaded this little resource which supports simple Python programming with the CPC traffic light kit.

The CPC Traffic Light can be bought here.

Thank you to everyone who has downloaded this free resource from either iBook store or from our free PDF download.

10 engaging python projects


PiFace menu

(Updated 25th March)

Since getting the PiFace control and display at the end of February I have been keen to write a simple menu which can run on the Pi the whole time.

pi face menu

My prototype Python script generates 5 menu options which are accessed via the push buttons. Once pressed they either launch another script or run part of the menu script.

I intend to leave this running so I have included two buttons to switch off the back light and turn it back on again.

The clock option displays the current time for three seconds.

The code is still in development and is rather ‘clunky’ (if you can use such a term!) - but it does work!

Please feel free to use any aspect of the code and modify and improve!!!

Updated 25th March

I’ve not setup and mapped a generic Tv remote control - the next part will be getting the menu system to respond to different IR buttons. I don’t think I will have enough room for each menu item so I will explore custom images.

import pifacecad
import time

def update_pin_text(event):
        choice = event.pin_num
        if choice == 0:
                cad.lcd.write("Menu selected")
                import subprocess
                p = subprocess.Popen(["sysstart"])
                output, err = p.communicate()
                cad.lcd.write("1:Welcome  2:GS\n3:Clock [4/5]:BL")
        if choice == 1:
                cad.lcd.write("GSL countdown\nselected")
                import subprocess
                p = subprocess.Popen(["GSL2014"])
                output, err = p.communicate()
                cad.lcd.write("1:Welcome 2:GS\n3:Clock [4/5]:BL")
        if choice == 2:
                cad.lcd.write("Current time: \n")
                cad.lcd.write("1:Welcome 2:GS\n3:Clock [4/5]:BL")
        if choice ==3:
        if choice ==4:

cad = pifacecad.PiFaceCAD()
cad.lcd.write("Pi menu Use the \nbuttons")
cad.lcd.write("1:Welcome 2:GS\n3:Clock [4/5]:BL")

listener = pifacecad.SwitchEventListener(chip=cad)
for i in range (6):
        listener.register(i, pifacecad.IODIR_FALLING_EDGE, update_pin_text)


Reaction time game

Pi Project 4: A simple reaction time game

I will add more detail about the build later but here is the code.

I have a green LED connected to GPIO output 7 and a red LED connected to output 3.

I have a switch connected to input 23.

The program starts with the Green LED on, after a random time period (1-10 seconds) the LED turns off and the red one comes on. It then measures the time taken to press the switch.

import time
import random
import RPi.GPIO as GPIO
GPIO.setup(23,GPIO.IN, pull_up_down=GPIO.PUD_DOWN )

GPIO.output(3,0), GPIO.output(7,0)

print ""
print ""
print ""
print ""

print "You may begin now"
print "The Green light will come on for a random amount of time"
print "It will then change to red"
print "As soon as it changed to red hit the blue button"
print "The game will start in 5 seconds"

r = random.randint(1,10)

GPIO.output(7,0), GPIO.output(3,1)

start = time.time()

    while True:
        if (GPIO.input(23) == 1):
            end = time.time()
            print "you pressed the button"
            elapsed = end - start
            print "it took you "
            print round(elapsed,2)
            print "Try to beat that next time"
            GPIO.output (3,0)
            GPIO.output (7,0)

            GPIO.output(7,0), GPIO.output(3,1)

except KeyboardInterrupt:


Philip has discovered Python

Philip has discovered Python!

July 2012 was a great time for the Raspberry Pi in our house. We were a very early adopter and it became a very popular device during the summer holiday.

We made a number of videos showing some of the simple scratch games written by Philip at the age of 7. Whilst not being technically the most advanced pieces of code it did start him on a journey of discovery in coding.

Fast forward 18 month and my first Pi is now sat in the cupboard under the stairs as a file server and Philip has moved on from Scratch to writing batch files based on sample code he found online.

After much persuasion Philip encouraged me to buy another Pi for him to use for coding and playing Minecraft.

So here it is .....

Raspberry Pi

After getting onto the Pi store we decided to download a couple of game tutorials. The first one we found was for a Raspberry Pi version of space invaders. After playing a few games Philip said “I wish I had more lives and I didn’t die when it hits the bottom”. This was a great cue from me to say - “If we have a look at the code we might be able to change it!”

This was the moment where the penny dropped for Philip.

After having such good fun with Scratch I do hope that this develops into something he will be interested in!