Monday, September 24, 2012

Hackable places

I recently got my Raspberry Pi, a cheap single board Linux computer designed for education and hacking. I already have OLPC laptops and Arduinos as hackable places, but it looked like fun. Now I have it I can assess it as a learning tool in home and school contexts.

You can buy from Element 14/Farnell or RS Components  for A$38 but after freight it was A$56 (A$1 is approximately US$1). It arrived from Element 14 in 2 days. Home/school will probably have some of the accessories at hand, but if not the full cost is:

 Rasperry Pi with tax and freight           A$56
 Power supply 5V micro USB              A$20
 Memory card 4GB                             A$15
 AV cable                                            A$2
 USB keyboard                                    A$14
 USB mouse                                         A$5
 Television                                            ?
 Total                                                   A$112+

Compare that with another Linux computer designed for educational hacking, the OLPC laptop at $188 or more realistically $200+ with freight. Consider an old unused PC or laptop as a hacking platform.

Writing the OS, Raspian (Debian) Wheezy, to the memory card was easy, once I really read the instructions. I used the Linux method to setup the card using dd an OLPC XO laptop, I did have to use another computer to unzip the 1.9GB OS when it failed on the XO.

Not having a hi definition TV I used composite video (the yellow plug). I was disappointed with the screen resolution. Its presumably quite good on a hi def tv.

Rasperry Pi GUI, LXDE displayed on a composite TV

Next step was to run the Raspberry Pi remotely from an OLPC laptop using ssh.

Get the IP address of the raspberry Pi

  hostname -I

That's the last time you will need the Rasperry Pi keyboard or TV unless its IP address changes. On the OLPC XO laptop in Terminal enter:

ssh -X ipaddress -l logon 
for example
ssh -X -l Pi

That brings up the Raspberry PI command line interface on the XO. You can run xwindow programs, they display using the XO's window manager.

The Rasperry Pi File Manager displaying on an XO

You cannot start the Pi's desktop with the usual startx, but you can run almost everything using the XO desktop eg

pcmanfx  the file manager
midori      web browser
leafpad     text editor
idle          python IDE
lxtask      the task manager

Though startx does not start the Pi desktop but startlxde gives some success. In Sugar, the desktop is always hidden but the bottom menu bar is available. Using OLPC build 3 13.1.0 in Gnome, the Pi's desktop is visible, possibly due to a bug where the XO's Gnome desktop is not displayed.

The Pi's desktop, LXDE displaying on an XO running Gnome, (build 3, 13.1.0)

So why use the Pi at home or school? School is unlikely to have a class set of TV's or space for them. Home is unlikely to have the USB keyboard, power supply and cables. But both school and home are likely to have older underpowered PC's or laptops (which can be reimaged to Linux if desired) and used as hacking platforms. Those with OLPC laptops have a computer, purpose designed for hacking.

The Pi does provide an additional hacking platform, having multiple platforms is a good thing, not all tasks 'click' or work for all learners.

The Pi can be used as an I/O board like the Arduino. Unfortunately its I/O pins are not protected and can be damaged by 0V (27mA) or voltage >3.3V. Compare with the Arduino I/O which can source up to 20mA to ground and be connected to 5V.

Labels: , , , , ,

Sunday, June 10, 2012

Galton Box

The Galton box, is a device invented by Sir Francis Galton to demonstrate the central limit theorem, in particular that the normal distribution is approximate to the binomial distribution. The machine consists of a vertical board with interleaved rows of pins. Balls are dropped from the top, and bounce left and right as they hit the pins.

Galton Box in Game Maker, source and executable

Galton Box in Turtle Blocks Source

  • At the moment the balls have an equal chance of going left and right. What happens if you change it? Why?
  • Change the number of rows. What happens? Why?
  • What is the relationship between this and a similar experiment in coin tossing Turtle art , Game Maker ?

Labels: , , , ,

Thursday, February 16, 2012

XO laptop in Antarctica

The laptop was on holidays. Its most southerly point was 68°12’S 69°28’W
This photo was taken at Orne Harbour 64˚37’S 62˚32’W

Labels: , , ,

Saturday, January 21, 2012

Arduino and the XO laptop

The Freetronics Leostick is a low cost Arduino board. (It is presumed to be low cost, it was cheap enough to place into the satchels of the attendees of LCA2012.) The XO-1.5 already has 2 channel analogue input, an Arduino board can add a lot of extra input and output channels.

This could facilitate a number of low cost science and robotics experiments in schools, experiments at a cost suitable for developed and even developing countries.

There are a number of ways such a board could be used:
  • from the Arduino IDE
  • from TurtleArt, Firmata running on the Arduino
The second version is probably the most practical for classroom use. Once the Leosticks are loaded with Firmata (and this could even be at the factory) all that is requited is TurtleArt drag and drop programming.

Installing the Arduino IDE onto a XO-1.5 laptop (OS880)
In terminal enter the following

sudo yum install arduino

This installs an older version (0021), more importantly it installs all the dependencies including Java and avr-gcc. It is a 60MB download which expands to 200MB of storage, be warned it uses up a lot of precious space.

The IDE can be started from the Gnome menu or with the command


but it does not have the permissions to see the Arduino board on the USB serial port so start it as root (maybe why)

sudo arduino

The IDE can then be upgraded to version 1.0. This is the version recommended for the Leostick. Download version1.0 from
The file arduino-1.0-linux.tgz uncompresses with the Gnome archive manager. Uncompress it to a convenient location, if for example if you uncompress it to Documents, you will find a directory arduino-1.0 in this directory.

You now have 2 versions of the program, 1.0 (at /home/olpc/Documents/arduino-1.0 ) and 0021 (with components at /usr/share/doc/arduino-0021 and /usr/bin). The later versions 1.0 uses the dependencies installed with the earlier one 0021.

As described at uncomment the following lines in /home/olpc/Documents/arduino-1.0/hardware/arduino/boards.txt

(or in version 0021 you would need to add them) Leonardo

Launch the Arduino IDE (sudo /home/olpc/Documents/arduino-1.0/arduino), and select Tools > Board > Arduino Leonardo.
to select the Leonardo hardware

select Tools > Serial Port
a new device appears with Leostick plugged in, dev/ttyACM0, select it.

You can now upload example programs, eg blink, to the Leostick.

NOTE: this will overwrite the program that came with your Leostick that plays a tune, watch
for the original program

Controlling the Arduino with Turtle Art
Load Firmata software into the Leostick, this can be done on an OLPC, another Linux PC or Windows. Once this is done the Leostick can be used as a I/O expander for Turtle Block drag and drop programming. No Terminal or Gnome work would be needed.

The version here works for older Arduino boards on Sugar 0.88 It needs patching at, line 834 as described in the link above. The baud rates of Turtle Art and Firmata need to be patched.

Sugar 0.88 (Fedora 11) recognises an older Arduino board as as serial device but not the Leostick. Later Arduino boards are dev/ttyACM0

This version is hard coded to dev/ttyACM0, that means it only works the first time the Leostick is plugged in and not at all for older Arduino boards. It is patched and works on Sugar 0.94.

The quick and dirty patches are:
Turtleartactivity line 835
line 868 commented out
# palette_toolbar_button.set_expanded(True) line 273
# self.fd =, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
self.fd ='/dev/ttyACM0', os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)

see also:

Labels: , , ,

Wednesday, November 09, 2011

Turtle checksums

Here is a Turtle Art program that calculates the checksum of a South American 7 digit identity number. Source. You can get the algorithm as a spreadsheet

How many ID numbers share a checksum?
Find 2 ID numbers with the same checksum, not by trial and error
The 'key' is 2987634, what restrictions are there on the key that could be used?
What is the effect of having the digit 0 in the key?

Labels: , , ,

Sunday, October 09, 2011

XO-1.75 seismograph

A seismograph program which uses the accelerometer of the OLPC XO-1.75 laptop

The x,y,z accelerometer readings are saved in boxes x,y,z. Action 1 computes long term averages for these readings, (boxes a,b,c), 5% of the current reading is added to 95% of the long term average to compute a new long term average.

Action 2 determines a threshold of random noise which is ignored. It sums the squares of the deviation from average (x-a)^2 + (y-b)^2 + (z-c)^2 . If this figure exceeds 10, the screen is turned red to indicate that an event is occuring.

Action 3 prints the sum of the squares of the deviations and the x,y,z deviations.

Project source

  • When an event occurs, graph the 3 channels (a)
  • Save the 3 channels events with a time stamp for exporting into a spreadsheet (b), (c)
  • Set up a network of laptops, an event is considered to have occured if all register it. (Use turtle position to share data)

Labels: , , ,

Sunday, July 31, 2011

East Timor continued, video

(10 minutes)

Or see the short version (3 minutes)

Labels: , , , ,

Sunday, July 17, 2011

East Timor continued

Saturday morning

We went to Hera market in the morning.
Hera Market

In the afternoon Tom worked on the server and I tried to learn more Tetun.

The others went to Sidhara village to see a bread making demonstration.. An irrigated community garden has been established there.
Bread oven

Later we went snorkeling at Caz Bar beach, up to the big statue at Christo Rei, the supermarket and dinner at a restaurant on the beach.

Caz Bar beach, Dili

Christu Rei

The power went off at sunset and didn’t come back for 24 hours.

Sunday morning
Power still off. Up to the school to pick up 5 laptops. Ran the generator for an hour or so to cool the refrigerators and charge the laptops. Tom worked on the school server, now working if a config file on the laptops is changed. Carol and I tried out Activity sharing on an Ad Hoc network.

Sunday afternoon, church service at Sidara village.

Sidara Village

Monday morning
Tom worked on the server
Carol and I worked on activity sharing

Up to school to do Gcompris Activity with class 2A

Monday afternoon Tom worked on server and I watched

The server works!!

Monday night Into dili and stayed Dayan and Merna Barbossa of WEC. Night soccer match didn't happen because power was off.

Off to Care this morning, in principle permission to use digitised Care resources on the laptops.
Care Dili

Labels: , , ,

Saturday, May 14, 2011

Graphing pitch and volume

Different ways of displaying pitch and (measured a little later) volume using TurtleArt

Direction = pitch, radius= volume

with only dots at the end of the line

colour determined by volume (measured a little later again)

x = pitch, y=volume

  • No code is given here, create these graphs
  • Make other graphs
  • A third variable to graph is number of occurrences of a pitch/volume pair
  • Can you get useful information from these graphs? Can you tell speech from music, TV program from advertisment?
  • The pitch block only shows the pitch of the loudest component. This is derived from a FFT (Fast Fourier Transform). Can you program a Python block to show all the spectral components and their amplitude? (Look at the source to see how the FFT is done)
  • With more than one laptop you can log more data. Can you combine data from multiple laptops and graph it? How will you synchronize the data?

Labels: , , ,

Sunday, May 08, 2011

Turtle calculus

Its easy to plug in various functions as a graph's gradient in Turtle Art. The resulting graph is the integral of the function used as the gradient. In the below case, the gradient is 1 and its integral is a straight line, f(x)=x

Plug in a linear gradient, -2+x/100, and make a parabola with zero crossings at x=0 and x=400

A quadratic gradient generates a cubic with zero crossings at x=0 and x=300

The integral of sin is -cos
(by the chain rule)

making dy/dx =y gives an exponential curve
but a nonzero value at x=0 is necessary, in this case forward 1 means f(0)=1
starting at 0, f(0)=0 has a solution of a straight line f(x)=0

Graph for negative x
Graph the exponential for f(0)=-1 explain
The exponential above is for dy/dx = y/100 what exactly is the formula for the graph?
Find more interesting integrals
Graph the derivative of a function
Iteratively solve d2y/dx2 =-y
Explain the offset in the graph of -cos
A step size of 1 is used, what error does the step size introduce?

Labels: , , , , ,

Sunday, April 24, 2011

Nepal Micro Hydro

The distribution of the OLPC (One Laptop Per Child) into the developing world including places without mains power or internet, raises the question of appropriate power technologies. A selection of small hydro schemes in Nepal below are particularly interesting in that none have road access.

Water wheel grinding cornflour

This one below Ghandruk, in the Annapurna region. There are many water mills in the region.

1 kW approximately micro hydro
Provides power for the tea house at Deurali Pass, near Ghorepani.

10 kW approximately micro hydro

This provides power for the village of Ghandruk.

Labels: , , , ,

Friday, April 08, 2011

Turtle division drill


This could be turned into a 2 player online game. Writing to the screen is shared in a shared session. Add a score display and displace one player left and the other right.
Hint: you cannot remotely erase the other player's screen but you can draw a blank rectangle.

Labels: , , ,

Wednesday, April 06, 2011

TurtleArt die or spinner

Enter the number of faces (2-9) and then it tosses the die when you press a key.

Labels: , , , ,

Monday, April 04, 2011

Fractions and decimals 4th grade maths

TurtleArt project to meet outcomes 4N3 to 4N6 in the 4th grade math curriculum. Enter a single digit numerator and denominator to hit a target which is expressed as a decimal 0<1.

Open the source and paste into TurtleArt.
Could be improved with rewards and score.

Multiplication version

Enter the number of balloons. If the turtle hits the top balloon, all are popped.


Labels: , , , ,

Sunday, April 03, 2011

Turtle flip and rotate, 4th grade maths

An activity in Turtle Art to meet the 4th grade curriculum item "4.G.7 Describe and apply techniques such as reflections (flips), rotations (turns), and translations (slides) for determining if two shapes are congruent"

A number of shapes are randomly generated (in this prototype just a right angle triangle and a trapezium) unrotated and unflipped on the left and randomly rotated and flipped on the right. The student flips and rotates to match the two polygons.

In boxes (variables) 11 to 19, the trapezium is stored, distance, rotation, distance, rotation ... and terminated buy -1. Similarly, the triangle is stored in variables 21 to 27.

poly is a random number, either 10 for the trapezium or 20 for the triangle. Rotate is a random number, (0-7) x 45 and flip is either -1 or 1.

The program loops, waiting either a 'F' key, 102 or a 'R' key, 114. The polygon is drawn once on the left unflipped and unrotated (netflip =12 and netrotate =0) and drawn once on the right flipped and rotated (netflip = flip x userflip and netrotate = rotate + userrotate)

drawpoly draws the polygon specified in box 11-19 or 21-27 terminating on a -1 value, the polygon has rotation and flip specified in netrotate and netflip.

The activity could be improved with a score or reward system, sideways translation, more polygons and randomly congruent and incongruent pairs


Labels: , , , ,