http://www.youtube.com/watch?v=E1wt5ywUo9M
Le code de Lego (conçu en Bricx Command Center) :
#define puissance 75
temps d’arrêt de #define 200
#define upTime 200
#define TimePerTarget 2000tâche main()
{tourner longtemps ; / * la variable pour l’angle de l’enregistrement * /
long nothit ;
welke int ;
int m ;
score d’int ;
longtemps, time2 ;TextOut (0, LCD_LINE2, « Angle sur PortA ») ;
score = 0 ;
TextOut(0,LCD_LINE7,"Score:") ;
NumOut(40,LCD_LINE7,score) ;tout en (vrai) {}
OnFwd(OUT_ABC,Power) ;
Wait(Downtime) ;
OFF(OUT_ABC) ;Wait(2000) ;
Welke = Random(3) ;
NumOut(0,LCD_LINE4,welke) ;Si (welke == 0) {m = OUT_A;}
Si (welke == 1) {m = OUT_B;}
Si (welke == 2) {m = OUT_C;}OnRev(m,Power) ;
Wait(Uptime) ;
OFF(m) ;Wait(400) ;
nothit = MotorRotationCount (m) ;
tourner = nothit ;
NumOut(0,LCD_LINE6,nothit) ;temps = CurrentTick() ;
même si (nothit == rotation) {}
tourner = MotorRotationCount (m) ; / * Lecture moteur angle [degrés] * /
TextOut (0, LCD_LINE5,"") ;
NumOut(0,LCD_LINE5,rotate) ;
TextOut(40,LCD_LINE5,"deg") ;Si ((time+TimePerTarget) < CurrentTick())
{faire tourner = rotation + 10;}}
OnFwd(m,Power) ;
Wait(Downtime) ;
OFF(m) ;score = score + 1 ;
TextOut(0,LCD_LINE7,"Score:") ;
NumOut(40,LCD_LINE7,score) ;}
}