Der Inhalt dieser Seiten steht unter Creative Commons Lizenzvertrag

NXT Robots are a genius playground.

I use the nxc programming language

Fighting Sumo with 2 robots is great fun

Simple howto

call the build process with the following commands

./nbc sumo.nxc -O=sumo.rxe -v=105
sudo ./t2n.static -v -put sumo.rxe

Sample program

int freie_bahn;
int turning;

task move_forward()
{
 while (true)
 {
  if (turning == 0)
  {
   if(freie_bahn == 1)
   {
    TextOut(1,LCD_LINE1,"forward",true);
    OnRev(OUT_BC, 100);
   }
  }
 }
}

task turn()
{
 turning = 1;
 TextOut(1,LCD_LINE1,"turn",true);
 Off(OUT_BC);
 OnFwd(OUT_BC, 100);
 Wait(7000);
 OnRev(OUT_B, 100);
 OnFwd(OUT_C, 100);
 Wait(2000);
 turning = 0;
}

task check_sensors()
{
 while (true)
 {
  NumOut(1,LCD_LINE2,Sensor(IN_2),true);
  NumOut(1,LCD_LINE3,SensorUS(IN_3),true);
  if (Sensor(IN_2) < 50)
  {
   freie_bahn = 0;
   if (turning == 0)
   {
    StartTask(turn);
   }
  }
  else
  {
   freie_bahn = 1;
  }
 }
}

task main()
{
 freie_bahn = 1;
 turning = 0;
 Precedes(move_forward, check_sensors);
 SetSensorLight(IN_2);
 SetSensorLowspeed(IN_3);
}