Thymio with Simple Rotor - Visualising a Loop

Thymio with Simple Rotor - Visualising a Loop

This basic Lego construction allows a Thymio robot to use a proximity sensor to detect its own motor rotating.


With a short VPL program it is possible to both run the motor and "watch" it running using a proximity sensor.


The proximity event is triggered regularly every time the rotor arm occludes the sensor. The sound and lights actions provide visual and audible feedback that the sensor has detected the rotor passing.

In effect, it is a mechanical model of a timed loop.

(Note that, since the proximity sensor is polled at 10Hz, the performance of the code is dependent on the speed of the motor. Too fast and Thymio may fail to detect all occlusion events, too slow and multiple events may be triggered for each sensor pass.)

Adding States

In the advanced mode of VPL we can use our regular event to set states and build a more complicated behaviour.

This VPL code switches between two states every time the sensor detects the rotor arm passing. The states are indicated by the orange circle leds and by the colours of the top led pulses.


One aim of this construction and code is to introduce state setting triggered by an event in VPL.

To make this tangible and (hopefully) easy to understand I have used a physical event which occurs regularly (the rotor arm passing the sensor).

Hopefully this will help children and teachers to build their understanding and then progress on to using the (more abstract) timer and alarm blocks in VPL to set states.

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