Shop OBEX P1 Docs P2 Docs Learn Events
What's wrong with this codes: — Parallax Forums

What's wrong with this codes:

JarvanJarvan Posts: 31
edited 2013-12-03 10:56 in Learn with BlocklyProp
IMG_20131201_213152.jpg


The second Ping sensor on the right as the picture shown above. In order to make the Activitybot moves parallel with the wall.
  while(1)
  {
      int n1,n2;
      n1 = Right_distance();
      pause(500);
      n2 = Right_distance();
      if(n1 > n2)  // moving close to the wall 
         drive_speed(30,40);
      if(n1 < n2)  // moving away to the wall
         drive_speed(40,30);
      else drive_speed(30,30);
  }

When the ActivityBot moves away, it can turn back, but if it moves close to the wall, it can not turn to the other side.
It's seems to simple but I can find what is wrong.
768 x 576 - 168K

Comments

Sign In or Register to comment.