This document is meant for youngsters, which is why the style is different from the rest of the site.
This guide will take you through several exercises with the Thymio II. Step by step you will learn how to program it, to control the LEDs, the motors and so on. By the end you will have made a new behaviour, or mode, of your robot all by yourself!
There are several parts to this guide, each one concentrating on a different aspect.
Getting to know the robot and Aseba
Start by taking hold of the robot. You can switch it on by pressing the middle button. Then you can choose one of the existing modes by pressing an arrow button: Thymio changes colour. You can start this mode by pressing the middle button. In the rest of this exercise you are going to create your own mode, adding a new choice to the colours.
Connect your robot to the computer with the USB cable and start Aseba Studio. Aseba Studio looks like this:
- These buttons are used to load and execute (carry out) the code (instructions) which has been written.
- This window shows an overview of the state of the different parts of the robot: sensors, actuators, variables.
- Here you see the available functions and events which can be used in the code
- In the centre we are going to write our code. That is what will tell the robot how to behave.
- Here the constants can be created or looked at.
- Here the events can be added.
- This line tells us if our instructions are complete and correctly written.
The sensors
You can use the Aseba Studio to look at the values of the robot's sensors in the menu at the left side. A sensor is used to measure something physical (real), such as light, sound or an acceleration, and convert it into a numeric value which the robot can understand and use. For example the distance sensors at the front of the robot allow the robot to measure the distance to nearby objects. It is the value prox.horizontal in the Variables window. If the auto box is crossed and you put your hand in front of the robot, you can see the value changing.
In the first picture you can see that the sensors see nothing (0). In the second one, with a hand in front, the values are high.
What is the code?
The code is a series of instructions for the robot, which it will execute and which determine its behaviour. The code has to be written with special key words which the robot can understand; you cannot just talk to it in English.
A trick to write code more quickly
In Aseba Studio, you can drag the keywords from the side menus into the main window. For blocks of similar code, you can copy-paste them (Ctrl-C, Ctrl-V in Windows and Linux, or Command-C, Command-V in Mac).
Comments
What is written in the code is interpreted by the robot as instructions. You may want to write something for yourself perhaps to explain what the instructions are for. In this case you can make comments. The # sign shows that the text following in that line is not an instruction for the robot. We shall see an example later on.