PS3 controlled Edukit robot


Edukit 3 robot kit, revamped with 4Tronix picon zero board and python program to control it with a ps3 wireless controller. The pizero has the dongle for the ps3 controller in its single usb port, and is arranged to boot automatically into the python program driving the robot. A red led lights when the system is ready for action. The left hand joystick is sensed and used to control the motor speed and direction. A button on the controller is sensed to initiate shutdown when finished, so the whole process is automatic and doesn’t require any keyboard, mouse or screen. software is availabe for download at:

video of the robot in operation is here

Mozart KV516 f Musical Dice Game

Here as promised is the code to perform the musical dice game to generate Waltzes and Contredanses in the style of Mozart. This version of the game was published first in 1788. I am indebted to Martin Tarenskeen who published python scripts to simulate the game as far as the Waltzes are concerned, utilising the music engraver program Lilypond and the midi playing program Timidity.You can download his version here.

I have modified his original script and added the code to generate the Contredanses, which are included in my dice game version produced by Philips entitled Musikalisches Wurfelspiel KV516 f, their product nunber being 422 500-0

I have also altered the scripts to use version 2.14.2 of Lilypond which is the version currently available on the Raspberry Pi.

Bascially the dice game throws two dice and uses the sum of the numbers thrown to select in turn the 16 bars needed to compose the Waltz or the Contredanse. These are printed on 176 cards (1 set for the Waltz and a separate set for the Contredanse). A separate booklet holds a lookup table, which selects the bar required for each throw. There are 11 possibilities for each bar matching the sums 2 to 12 for each pair of dice throws.

For example if the first throw give a 2 and a 5, this gives a total of 7 and the lookup table shows that for the first bar of the waltz, choice 7 give bar number 104 of the 176 available.

If you are composing the contredanse, then 7 chooses bar 138 of the 176 contredanse bars.

The python script holds an array containing the 176 bars, and each location contains the note pitches and durations for that bar. The left and right hand staves are held separately in the array. the program simulates the throwing of the dice, and adds the appropriate bar notes to produce a source lilypond file containing the notes. This is then compiled by lilypond to produce a printed score (in this case as a png file, although it could be a pdf or jpg) and a midifile.

I have included a simple bash script appropriate to the Raspberry Pi to run the python script twice, first generating a waltz and then a contredanse and then to display them one after the other in the Midori browser whilst playing them using Timidity to the audio output on the Pi, selectable to HDMI or 3.5mm audio jack.

I will not go into the scripts in detail. The main script is This parses the various input parameters, and generates the dice throws and the bar choices, using procedures contained in the separate, which contains the lookup tables for the two types of music.

Dicewalz then chooses the appropriate output file, in this case a lilypond source file, which is generated by calling either or These scripts contain the arrays with the 176 bars of note data. The relevant bars are assembled into  a file, which also contains details of time signature, title, tempo etc. If you use the bash script the files generated are called for the waltz, and for the contredanse. It is worth inspecting these to get an idea of how lilypond works.

The lilypond compiler is then called for each turn, using parameters which generate a png file for the output score. Thus playme.png and playme2.png are produced, together with the midi files playme.midi and playme2.midi.

The script carries out one further task. It uses the convert progam which is part of imagemagick to crop the png files so that they display nicely in Midori. Otherwise they are A4 size which is rather large.

So in order to use these files on the Raspberry PI you need the following.

An up to date installation of raspian Wheezy.

on this you should perform

sudo apt-get update

sudo apt-get install lilypond timidity

sudo apt-get install imagemagick
(this is only needed for the convert program)

You can then download a zip file of the programs here

There is a README.txt file which gives further information about using the files, together with the originalREADME.txt file which accompanied Martin Tarenskeen’s program.

Sample printouts are shown below, and you can hear two pieces here


Sounding-Off… The final Part

Phew! The final part of the Sounding-Off project is now complete and published here

It shows you how to generate the long tunes  and also how to generate tunes on the Pi which are then played automatically on a Mac computer under the control of the Pi.

It also illustrates the use of cron to turn any of the tune generation or playing programs into an alarm clock.

The Endtonerow.previewOf the Sounding-Off Projecttone-2013-08-10-20-27-10


WiFi to ethernet adapter for an ethernet-ready TV article

i have just completed my first article for the site. It is available on a separate page here
t describes in detail how to setup a Raspberry Pi as a router, fed from the wireless lan to a TV (or computer or network switch) connected to the ethernet port. This enables a device with an ethernet port but no wireless adapter to connect to your local network (and hence the internet) via a wireless connection.

Let’s get started

Having had two Raspberry Pi(s) for some time, I thought it was time to put down some thoughts on what I’ve been doing with them. They are great fun to use, and complement well my previous interest in using Lego Mindstorms kits, the results of which can be seen here.

Both my Pi are model B but the early versions with only 256Mb of RAM. So far this has not been a problem, but I may get a 512Mb model later. I have played with various distributions. One of the great things about the Pi is being able to change the SD card so easily and switch from one distribution to another. Thus one minute it is an XBMC system, the next a Wireless Access Point, and the next (my latest project) a WiFi to ethernet adaptor to allow my TV to connect to the internet via my ADSL Wireless Router. Along the way I have had a play with breadboards and programming the GPIO, and one novel feature is the pink case on the Pi shown in the photo which is produced on a 3D printer at the School where I used to work.

I think my first technical post will be to describe the TV WiFi adaptor which I have just finished. I’d better make a start on writing it up!