| What you need ? |
First, a robot built with the Lego Mindstorms.
You can take a look on the robots buit by my students.

You need the Esterel compiler. You can download it from here.
And an extension (shift click on the link to save it) to the Esterel compiler wrote by Xavier Fornari, a member of the Esterel team, to allow the Esterel compiler to produce automatically the C code needed for legOS. Take a look here to see how to use it.
| What to do ? |
Start by writing your Esterel program keeping in mind the sensors you want to used. In the small example below, we use 2 touch sensors on port 1 and 3 and 2 motors on port A and C.
legOS allow us to set the speed and the direction of the motors. We can also write string to the lcd screen.
If you want to use the extension to the Esterel compiler you must use some specific names for the inputs and the outputs. Take a look on the API.
| A simple example. |
| module
lego1 :
input TOUCH_1, TOUCH_3; output MOTOR_A_SPEED(integer), MOTOR_C_SPEED(integer), MOTOR_A_DIR(integer), MOTOR_C_DIR(integer), CPUTS(string); relation TOUCH_1 # TOUCH_3; constant MOTOR_FWD, MOTOR_REV, MAX_SPEED : integer; var t : integer in
|
| After. |
After you have write, compile and simulate your Esterel program you may want to try it on your robot. Next, I assume you have installed the extension to the Esterel compiler.
Use the -s option if download fails. It tells to firmdl3 to download slowly.
The -p1 stands to tell to dll to download the program on slot 1. You can download only one program per slot but I thing you have access to 5 slots.
| Acknowledgment. |
Thank's to Xavier Fornari for the extension to the Esterel compiler which produces all the C code legOS needs.
MartinMartin.Richard@emn.fr