View unanswered posts | View active topics It is currently Mon May 20, 2013 1:42 am






Reply to topic  [ 2 posts ] 
Obstacle Course 
Author Message
Rookie

Joined: Sun Nov 18, 2012 11:49 pm
Posts: 6
Post Obstacle Course
After the lining tracking ends in the obstacle course, my robot turns in circles instead of stopping. I already watched and did what the video said to do but it's still spinning in circles. Can you help? Thanks! :D
Here's my code :-)


Attachments:
nxt_wait_for_push 2.c [3.89 KiB]
Downloaded 43 times
Fri Dec 07, 2012 1:19 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 380
Post Re: Obstacle Course
The problem you are seeing lies in this section of code:

Code:
 while(SensorValue(touchSensor)== 0)

       {

       if(SensorValue(lightSensor) < 45)

         {
       motor[motorC] = 100;
       motor[motorB] = 20;

        }
     else
      {

       motor[motorC] = 20;
       motor[motorB] = 100;
      }
    }


The questions you have to ask yourself are: What is the robot doing? What do I want it to do? What is this code telling the robot to do?

Remember, the robot will do only and exactly what you program it to do; it does not make assumptions.

Hint: Usually when a robot continues an action, it is stuck in a loop and the condition to stop it cannot be met.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Dec 07, 2012 1:27 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.