ShrimpingIT After-school Maker Club

St Leonard’s CE Primary School in Walton-le-Dale,Preston, Lancs has become the first (AFAIK :) ) primary to run an after-school ShrimpingIt Maker Club.

Having seen and talked to Mr ShrimpingIt (Cefn Hoile) at several events over the summer, I spent a very enjoyable evening up in Morecambe learning how to put a Shrimp together.

Armed with 10 Shrimp Kits, I now have 10 pupils in out Maker Club where they spent the 1st session being very excited but managed to install the Arduino IDE on 10 of the school laptops, have a look at a built shrimp and a full Ardunio Duo and watch me blink an LED!.

We talked about building a Simon Game, LED Dice, a spinning dice and the favourite was a bedroom alarm to keep out nosy siblings and parents!

Next time we will be actually building a Shrimp on a breadboard and getting them to flash LEDs!


So, we got to build our first Shrimps 🙂  I pre-installed the ATMega328s onto the board (had to install the bootloader on them the night before) and the pupils inserted the 2x22pf capactitors, then the crystal, the 10K resistor and the 100nf reset capacitor and bridged across the top of the chip with an LED between pins 19 (Arduino Pin13) and pin 8 (0V).  The pupils wanted me the check their wiring but I tried as much as possible for them to use each other.  Some did struggle with inserting the components in the right holes and it was apparent that what we need is a construction booklet for each person with clear diagrams and simple steps with the booklet also up on the whiteboard display.

We just had time for 2 club members to upload the blink sketch and flash their LEDs (make sure all chips are blank in future – some already had blink loaded!) and they changed the blink pattern to show that they were the ones instructing the Shrimps – they pulled the TxD/RxD/DTR cables off to show that the Shrimp was running the program by itself.  I just used coloured breadboard jumpers to connect the USB programmers to the breadboards as I hadn’t prepared short coloured wire leads.  I think for future sessions, some sort of pre-wired loom that just plugs straight into the breadboard would be a good idea.

Roll on Week 3 🙂


Only 2 out of the 10 Shrimps actually worked straight away – got another 3 working by end of club (only had 50 mins due to normal school over-running) and move onto actually determining what project they wanted to build (and therefore what bits I need to get over half-term) – they were interested in a POV project (5 people) but then 9 of them voted to build a bedroom “burglar” alarm.

Things learnt – between week 2 and week 3 – test and fix all breadboards – also definitely need to color code major rows on he board (such as pin1, pin7,pin8 and the DTR connection) and make sure using the rainbow coloured cables (green/yellow/orange/red/brown) for the programmer connection as 2 different colour schemes was too confusing.

So half-term – time to get some bits – maybe need 2nd breadboard for extra space for projects – also some 3xAA battery boxes for POV projects.
Good things – I ordered the PIR sensors, got plenty of LEDs, got 10 extra breadboards to give more space, tried and tested (and fixed) all 10 Shrimps 🙂
But…the PIR sensors didn’t arrive in time (China sourcing is cheap but slow 😦 ), decided to get club members to install S4A (Scratch 4 Arduino) on the laptops and upload the S4AFirmware to their shrimps – that took lot longer than it should/expected so we just ended up with 15 mins of actually programming our Shrimps but they all liked using a Scratch type interface and they switched their LEDs off and on and connected a switch to an input and saw that the S4A monitor changed value (they did query the words true/false).
As I only had one PIR sensor, we plugged that one in instead of the switch and we had a bit of fun in seeing if anyone could get near the Shrimp without setting it off.
Hopefully – next week, they will all be able to code up a simple alarm using S4A and maybe we can get around to the principle of an entry/exit delay

After-School ScratchPiBot Club

St George’s CE Primary School in Chorley, Lancs has become the first (AFAIK 🙂 ) school to run an after-school “Build and Race a RaspberryPi Robot” club.

The school have bought two Magician Chassis kits and two RaspberryPi plus other bits and the target is to build 2 robots that can race each other across the school hall, detect the wall, slow down, turn around and get back to the start line again.

The robots are going to be completely autonomous and the plan is to program them to do this in Scratch.

Week 1 has gone well, the teams have started putting their Magicican Chassis bits together, looked over their RaspberryPi’s and had a look at Scratch.

Hopefully next week they can get them to go for a manual test drive and start playing with Scratch

Week 2
Disaster, we couldn’t get a RaspberryPi to do anything in the school – it was working fine at home, but once in school (with a different USB Hub) it wouldn’t even recognise a mouse and therefore we couldn’t use the Pi to control the Robot.

Nevertheless, the club members completed the mechanical construction of both their ‘bots and powered them on and had a simple uncontrolled race across the classroom.  The girls ‘bot won as one the boy’s motor wires came loose and their’s started going around in a circle.

I’m going to go into the school this weekend and make sure that both Pi’s can be communicated with OK when they are on the school WiFi to make sure the teams can start programming them next week.

Decided we needed to do a quick 20 mins Scratch session and then found that I hadn’t installed it on the netbooks we were using ! 😦 10 mins later up and running and did the quickest Scratch lesson I’ve ever done (half the club did Scratch last year in Year 5). Then we moved onto running Scratch on one of the Pi connected to the robot motors (but tethered via USB cable) and we showed be could control the motors. We discussed using the IR Light sensors as line followors but time was our enemy again. Next week – those robots ARE going to roll across the floor

Having successfully had a run out at Manchester Raspberry Jam, I thought it would be plain sailing but no 😦  I couldn’t get a 2nd RaspberryPi to connect to the school WiFi so we had to make do with just the one (Which worked fine via VNC).  The roboteers coded up 2 different methods of controlling the bot – Method 1 was to control both motor speeds using up/down arrow keys and then increasing one/decreasing the other using left/right keys to steer.  Then they tried W/S for left motor Up/Down for right motor.  Next time I aim for them to re-code up a control system and race against each other.  We are both learning a lot 🙂

Determined to have 2 robots running but one failed on me 20 mins before the club start when I tried plugging in an IR Line Sensor. We did get the other robot racing across the floor using a simple scratch control program. We added on an Ultra-sonic range detector and sucessfully programmed the ‘bot to stop automatically when it got within 40cm of a Duplo brick wall – our first proper step into building an autonomous machine 🙂

Scratch controlling the GPIO on a RaspberryPi

This blog is now old hat – I’ve made a new version and much better instructions over in a new blog.

Click here


This post is intended to make it as Simple as Pi to get up and running and make your RaspberryPi control some lights and to respond to switches and sensors.

Minimum Requirements – a RaspberryPi with Raspbian installed and a working internet connection, a breadboard, some Light Emitting Diodes (LEDs), some resistors and some wire connectors. Total cost £5-£10.

How to get a Rapsberry_Pi to control the GPIO Pins from Scratch
Your RaspberryPi needs to be connected to the internet to install the software but not needed to run ScratchGPIO.

Copy the text below ( left click just before the s of sudo and drag right until all the text in the line, up to and including, as been selected) then right-click and select copy.  Open up an LX Terminal window and select Edit and the Paste that into an LX Terminal window and run it to download the installer.

sudo wget -O /boot/

and then if using Raspberry Pi as a normal user, then just type (or copy and paste as before)

sudo /boot/

but if your logging as as a different user then type

sudo /boot/ your_username

Either way will install all the necessary extra software and some simple examples.

(If you do not have internet on your Pi then,  put your SD card into a card reader and try using your browser to right-click and save the script direct to your SD card and then put it back into you Pi and run the second instruction)

Connecting Components Up
EXTREME care should be taken when connecting hardware to the GPIO pins. You can cause your Pi to die by connecting the wrong things together – only do this if your confident of your ability to follow instructions correctly 🙂
AT A MINIMUM – get a breadboard and use some female-male 0.1 leads (available from lots of online suppliers or your local Maplin shop)

Check out GPIO pin guides to make sure you know what pins are what.

Wire up Pin 1 (3.3V) to (at least) a 330ohm resistor – connect that resistor to the long lead of an LED and then connect other end of LED to Pin 6 (0V).

It should light up. If it doesn’t try reversing your LED.

Now move the lead from Pin 6 to Pin 11.

Run the special Scratch icon (Scratch GPIO) on your desktop.
(It is actually a completely normal version of Scratch, it just runs a little Python background program as well that handles communications between Scratch and the GPIO and automatically enables Scratch’s Remote Sensor Connections(RSC))

To test out control from Scratch, click on File then Open and then click on the My Projects button and select blink11 and click on OK.  Once the project opens, just click on the OK to enable Remote Sensor Connections.  To run the script just click on the Green Flag.

Your LED should now blink on for 1 second and off for 2 seconds – see trouble shooting if this doesn’t happen.

What more can I do with Scratch and the GPIO

You can control seven pins as outputs (Pins 11,12,13,15,16,18,21) and treat seven as simple inputs (7,8,10,19,22,24,26)

As you can see in the blink11 script , you can simply use a broadcast message telling Pins to go on or off (Up to 3.3V and down to 0V)

The valid messages are pin11on, pin12on, pin13on, pin15onpin16on, pin18onpin21on along with the corresponding pin11off etc messages.

You can also say allon and allloff.

And you can replace the work on with high and replace off with low if you want to talk in pure logic levels.

You can combine msgs together to make a single broadcast so to turn Pin11 and Pin13 on and all others off you can say

broadcast pin11on pin12off pin13on pin15off pin16off pin18off pin21off


broadcast alloff pin12on pin13on

to switch pins 12 and 13 on.  Alternatively you can use the pinpattern broadcast to achieve the same result e.g:

broadcast pinpattern110

This will also set just pins 12 and 13 on.

To check an input, you should go into the Sensing block and click on the word “slider” at the bottom and you’ll notice that you have pins 10,19,22,24,25,7 and pin8.  If you connect a switch to one of these pins (through a resistor don’t forget) to OV, then you can detect when the switch is open or closed.  The inputs will normally read 1 and go to 0 when they are connected (through a resistor) to ground.  Click on the checkbox next to pin7 and try it out.

Using variables instead of broadcasts

For advanced Scratchers, you can use variables instead (or as well as broadcast messages) .

For example:  create a global variable called pin11

To make pin11 go on  use

set pin11 on

To make is go off use

set pin11 off

On can be replaced with high or 1 and off can be replaced with low or 0 so that you can use whatever logic scheme you’d like.
To set all outputs on use

set allpins on

To use a “bit-pattern” to set/unset multiple outputs simultaneously use

set pinpattern 1010001

(this will set Pin 21 , Pin 16 and Pin 11 on and all the rest off)

Note – currently there is an unfortunate “bug” in Scratch in that it remembers variable states and only sends changes out.  Even when you press the Green Flag, it will not send the state of all the variables out, it will only send them when a variable changes.  I recommend setting any gpio variables to a . and then to their initial state in a Green Flag start-up script.

When GreenFlag clicked

set pin11 .
set pin11 off

Motor Control

Connecting a motor directly to a GPIO pin WILL BREAK YOUR RASPBERRY PI!!! So don’t do it!   Google about driving motors from a RaspberryPi!!!

David Ferguson supplied the diagram below which shows a very cheap way of getting 2 motors connected safely to your Raspberry Pi. The chip used is a very cheap (37 pence) one called a ULN2003.  Wire pin11 of RPi to Pin1 on ULN2003 and then RPi pin12 to ULN2003 pin2 and finally RPi Pin6 (Gnd) connects to ULN Pin8.

Then ULN2003 pin16 goes to one motor, ULN2003 pin15 goes to other motor.  The other connections on each motor are both connected to ULN Pin 9.

Finally connect a separate motor power supply (I use a 4xAA battery pack to give 6V) and CAREFULLY connect +ve to the ULN2003 Pin 9 and -ve to ULN2003 pin 8)


Once you’ve got your motor(s) SAFELY connected up, to control a motor, it is usually required to be able to not just switch it on or off but to vary its speed.

To do this in Scratch you can create 2 special variables called MotorA and MotorB and then assign these values from 0 (off) to 100(fully on)

MotorA controls pin11 and MotorB controls pin12.

e.g To make MotorA go at half speed use

set MotorA 50

To make MotorA switch off use

set MotorA 0

The motor variables can also be be used to simply vary the brightness of an LED.

Ultrasonic Sensor
Support for cheap 4pin ultrasonic sensors has been added.  To use one, connect Pin23 to the trigger or pulse input and connect the echo output (USING A 10K RESISTOR TO AVOID BROKEN PI!) to any of the input pins  (7,8,10,19,22,24 or 26).  This simple script

broadcast sonar7
wait 1

will send a pulse out on pin23 once per second and setup up a new sensor input called sonar7 that will display the distance (in cm) that the sensor detects.   (NB You need to have done at least 1 broadcast before the sonar7 sensor will show up as a valid option)

To test if the software necessary to control the GPIO is correctly installed open a LXTerminal session and type

sudo python

If this doesn’t give an error but doesn’t make a LED on Pin 11 blink then we have real problems Houston 😦

Try connecting the lead going to Pin 11 back to Pin 1 to make sure the LED lights up then just in case you have a loose connection.

Scratch GPIO future direction

Having played around with getting Scratch talking to the GPIO and thinking about making a Scratch mod (Razz) to have special blocks to switch pins off and on, I’m settling on just using simple broadcast messages (with the option of using variables as well) and making the default setup have 6 outputs and 2 inputs.

With the 6/2 combo people can flash a few leds and have a couple of switches or digital (easily make a full pedestrian crossing red/amber/green main lights red/green/white wait lights and a switch to cross.

I’m going to reserve build Razz for when I get my Aflex 2[url][/url] that I’m going to use as a prototype PriBoard

MarsCuriosity Lander Challenge

This weeks winning entry is at


In the old days, we all wrote Apollo 11 Lunar Lander games/simulators.

(Here is one I made in Scratch )

Well now its time to get your fingers/mouse moving again and write a MarsCuriosity Lander game/simulator.


Competition closed 26th Aug Sunday 8 pm GMT  but please feel free to submit a late entry just for the fun of it 🙂

At that time, we all upload somewhere and score/admire each others efforts. 🙂

Any level of game/simulator is acceptable – University PhD Teams programming in assembler as well as 6 Year olds programming in Scratch (possibly with some help from Mum/Dad) are all welcome.


I warn you now – my own effort will be awesome (in Scratch of course) and will be hard to beat 🙂

Use #mcsim on Twitter, or post comments here

Simon @cymplecy


(But you will get away with things as long as it RUNS ok on the Raspberry_Pi 🙂 )

Auto install a Simple Samba Setup

Updated 21Aug12 V1.1

Following on from previous blog I’ve tried to emulate MrEngmans brilliant concept of providing a single install script that does as much of the work as possible

His idea is to copy a file onto the SD while its plugged into a PC/Mac etc and then put the card into your RPi and issue one simple command

So  this is the file

simply copy it to the SD card while its in your PC/Mac and then put it in your RPi and issue this command

sudo /boot/

Alternatively (thanks to Jason Powell)


and then run

sudo bash

Note-some parts of the script can take a bit of time as the Pi needs to download stuff – just answer Y if asked questions BTW 🙂

When it sits there with New SMB passord: showing , enter raspberry as the password and then repeat it.
At the end, you should be able connect to your RPi from windows using username=pi  password=raspberry

Good luck