Skjutbana gjorda av Lego Mindstorm NXT
http://www.youtube.com/watch?v=E1wt5ywUo9M
Lego koden (designad i Bricx Command Center):
#define power 75
#define driftstopp 200
#define upptid 200
#define TimePerTarget 2000uppgift main)
{långa rotera; / * variabeln för inspelning vinkel * /
lång nothit;
int welke;
int m;
int poäng;
lång tid, time2;TextOut (0, LCD_LINE2, "Vinkel på PortA");
poäng = 0;
TextOut(0,LCD_LINE7,"Score:");
NumOut(40,LCD_LINE7,score);medan (sant) {
OnFwd(OUT_ABC,Power);
Wait(DownTime);
Off(OUT_ABC);Wait(2000);
Welke = Random(3);
NumOut(0,LCD_LINE4,welke);om (welke == 0) {m = OUT_A;}
om (welke == 1) {m = OUT_B;}
om (welke == 2) {m = OUT_C;}OnRev(m,Power);
Wait(Uptime);
Off(m);Wait(400);
nothit = MotorRotationCount (m).
rotera = nothit;
NumOut(0,LCD_LINE6,nothit);tid = CurrentTick();
medan (nothit == rotera) {
rotera = MotorRotationCount (m). / * Läs Motor vinkel [GRD] * /
TextOut (0, LCD_LINE5,"");
NumOut(0,LCD_LINE5,rotate);
TextOut(40,LCD_LINE5,"deg");om ((time+TimePerTarget) < CurrentTick())
{rotera = rotera + 10;}}
OnFwd(m,Power);
Wait(DownTime);
Off(m);poäng = poäng + 1;
TextOut(0,LCD_LINE7,"Score:");
NumOut(40,LCD_LINE7,score);}
}