Barcode Lightpainting

Inspired by Mariane Brodier's work on light painting, this project uses the Thymio robot and its colours to draw a picture taken with a camera in long exposure mode. While Mariane Brodier's drawing was based on a program encoding both displacement and colours, here the movement of the robot is defined by a line on the ground and the colours are coded in barcodes placed near the line.

Using Light Painting technique we decided to draw large figures composed of 'light pixels'. Hence, the program is quite simple, and the figure 'programming' is external to the robot, made by sheets of paper with a path of barcodes.

Basically, the code has a line tracking function, and a barcode decoding function. Thymio has two ground sensors. Thymio moves forward following a greyscale line with its right ground sensors, and decodes barcodes with its left ground sensor. Each barcode sets Thymio's LEDs differently, enabling it to change its colour as it moves forward.

Examples of results



This Aseba file .aesl contains the aseba source code generating this behaviour.

The Thymio program used for the video implements the following features:

  • start line following when forward button is pressed
  • stop line following when centre button is pressed
  • line following using ground sensor number 1 ([1])
  • simultaneously, look on the ground sensor number 0 ([0]) for barcodes along the line, decode the code, and change colour accordingly.


  • running: states if Thymio is in moving mode (1) or at rest (0)
  • counter: counts how much time has passed, proportional to how many bits of barcode have been read
  • state: reading (S_READING) or waiting (S_WAIT_SYNC) for sync, determines Thymio's behaviour along the track
  • intensityDiff: difference between the colour of the greyscale track under the sensor and the aimed value
  • code: the value of the measured barcode, corresponds to a colour in the colour tables r, g and b



In this code, we used six different constants:

  • S_WAIT_SYNC: used to set Thymio in the mode in which it looks for a barcode
  • S_READING: used to set Thymio in the mode in which it decodes a barcode
  • INTERVAL: used to set the time Thymio waits between measuring each blocks of a barcode. This can be tuned according to the robot speed.
  • BW_LIMIT: threshold used to determine if the block of the barcode Thymio measured was black or white
  • ON: value of the LED when totally lit (32)
  • OFF: value of the LED when totally shut down (0)

Start/stop (manual)

The button forward sets Thymio to moving mode(running=1), and state is changed to S_WAIT_SYNC: Thymio is waiting to cross a sync block to read its first barcode.
The central button stops Thymio: running is set to 0, motors are stopped and LEDs are turned off.

Line tracking


The Thymio robots tracks the line with its right ground sensor. The line is about 3 cm large and its colour spans from black on the right to white on the left, taking all grey levels in between. A mean value on the greyscale track is chosen to be followed, the robot's trajectory is adjusted to stay around this mean value. The steering is controlled by the grey gradient of the trail: any deviation intensityDiff under 170 (in absolute value) will be followed by a slight correction proportional to the difference, and according to the sign of the difference.
If the deviation is too important, the robot will spin until it finds the track again.

Decoding barcodes


The colours that Thymio displays are coded using the external barcodes that are along Thymio's path. Here, a white block codes a 1 and a black block codes a 0. In this program, 4 bits are used: a first sync bit (always black to set the beginning of the code), then 3 bits coding the colour.
As Thymio moves forward along the greyscale track (state=S_WAIT_SYNC), it is looking for the first sync line, which contrasts with the white sheet and sets state=S_READING. Then it reads the RGB coding bits and turns on the LEDs to the corresponding colours. After reading the barcode with its sensor[0], Thymio has a binary value coding for RGB LEDs. We can write the code as c2c1c0

Preprogrammed colours

In this program, colours are coded in a basic way: each bit c2 , c1 and c0 codes corresponding LED (r, g, b) on or off (0 or 32). This gives a good spectrum of basic colours if you don't have any specific colour in mind.

decimal code binary code r g b colour
0 000 x x x x
1 001 x x B blue
2 010 x G x green
3 011 x G B light blue
4 100 R x x red
5 101 R x B fuchsia
6 110 R G x yellow
7 111 R G B white

Colours can also be programmed for a specific picture. The choice of what colour corresponds to what binary code is completely arbitrary, you will just have to place the good barcodes in the right place when you want to draw. Here is a set of colours we used to draw some of our images:

decimal code binary code r g b colour
0 000 32 00 00 red
1 001 00 00 32 blue
2 010 00 00 00 x
3 011 25 20 00 yellow
4 100 07 05 01 pink
5 101 32 20 02 beige
6 110 32 11 00 orange
7 111 20 20 20 purple

Light painting

Light painting is a photographic technique used to capture the robot's light trail. A long exposure is necessary to capture all of the robot's pattern.
Light painting can be done with a dSLR (digital camera) with manual settings, or with a video camera and software composition. The camera should be set on a tripod above Thymio's path.


Camera settings

Your camera must have a manual exposure setting. As 30 seconds will not be enough to capture all of your picture (generally the standard maximal period), you must use your camera in 'bulb' setting, allowing it to capture light all along Thymio's path. The use of a shutter release cable or self timer is also advised to avoid camera shaking .

Track setting


To make 8-bit-like pictures such as those in the video, we set numerous parallel sheets with half-circle tracks as a transition between each row. As the robot's colours turn off every time it encounters a sync bit, you can either code each 'pixel' such as in the cat picture, or make continuous lines instead of dotted such as in Mario picture by coding only the first and last 'pixel'.
If you tape the paper sheets together, you might want to check that it doesn't affect the sensor's readings, or make the sheets overlap in a way that Thymio's wheels would get stuck along the track and avoid putting tape across the track or barcodes.

Here you will find the different tracks:


  • The battery indicator will create a green trail along your light painting (as on the Pacman picture). To avoid this, you can cover the LEDs with masking tape.
  • You can use only one Thymio going along the whole picture (as we did with the crab in the video) or you can use several Thymio, each drawing one or two lines of the picture (as we did with some versions of Mario). Indeed, drawing Mario with one Thymio took more than 20 minutes. After our first try, we set seven Thymio in parallel and made the drawing in less than 2 minutes.
  • You could also draw some monochrome pictures by coding only one colour and arranging the sheets in a way that Thymio draws the outlines of a figure. You could also draw your own line in the shape you want and use the basic behaviour Inspector.
  • You can find inspiration for this kind of 8-bit light painting in small bitmap icons, such as old video games graphics.



The barcode's length should be adjusted to Thymio's speed and measurement frequency. As proximity sensors take measurements every 100ms, there is a limit to the bit's length for a given speed. As Thymio takes measurements every INTERVAL, you will have to change this value if you change the robot's speed: the slower it goes, the longer it has to wait between reading two blocks.
Several thousands of colours could be coded with a combination of the RGB LEDs on a 0 to 32 scale, but the length of the barcode should be limited in order to maintain 'square' pixels. Another solution would be to code colours with a greyscale code instead of binary values.

Thymio Logo

In the end of the video, you can see the logo drawn by several robots.
To make this picture, 13 Thymio were set with a programmed path and launched using and remote control. The logo was approximately 5 meters long and 2 meters high!


Please feel free to post your own creations to this page.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License