Der Inhalt dieser Seiten steht unter Creative Commons Lizenzvertrag

Litte SumoBot Hotrod

Built 12.09.2010

Gear view:

Rear view:

Algorithm

nxc program

int rotating;
int running;
int direction;

task rotate()
{
 while (true)
 {
  if (rotating == 1)
  {
   if (direction == 0)
   {
    OnFwd(OUT_B, 100);
    OnRev(OUT_C, 100);
   }
   else
   {
    OnFwd(OUT_C, 100);
    OnRev(OUT_B, 100);
   }
  }
 }
}

task forward()
{
 while (true)
 {
  if (running == 1)
  {
   OnFwd(OUT_B, 100);
   OnFwd(OUT_C, 100);
  }
 }
}

task find()
{
 while(true)
 {
  NumOut(0, LCD_LINE1, SensorUS(S3), true);
  if (SensorUS(S3) < 65)
  {
   if ((rotating == 0) && (direction == 1))
   {
    direction = 0;
   }
   else
   {
    direction = 1;
   }
   rotating = 0;
   running = 1;
   Wait(3000);
  }
  else
  {
   rotating = 1;
   running = 0;
  }
 }
}

task main()
{
 rotating = 1;
 running = 0;
 direction = 0;
 Precedes(rotate,find, forward);
 SetSensorLowspeed(S3);
}