View unanswered posts | View active topics It is currently Fri Apr 18, 2014 6:51 am






Reply to topic  [ 2 posts ] 
why wont my line tracking code work? 
Author Message
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
Post why wont my line tracking code work?
I installed this code to my robot for my autonomous program i want it to turn then go forward and then follow a black strip of tape.
the robot turns and moves towards the black line but the sensors wont follow the black line, and the sensors are right on the line. its like the program ends as soon as the robot moves forward. Magiccode if you reed this i am sorry if the code is not organized, i didnt get how you told me to do it.

Code:
while (true)
{
 
    if(SensorValue(touch) == 1) // if the vex bumper id touched then it will run the program
    {
     motor[frontright] = 60; //this will make the robot turn
    motor[backright] = 60;
    motor[frontleft] = -60;
    motor[backLeft] = -60;
    wait1Msec(700);

    motor[frontright] = 60;
    motor[backright] = 60; //this will make the robot go forward
    motor[frontleft] = 60;
    motor[backLeft] = 60;
    wait1Msec(600);
   
    int threshold = 1500;


    if(SensorValue(right) > threshold)
    {

    motor[frontright] = 60;
    motor[backright] = 60;
    motor[frontleft] = 0;
    motor[backLeft] = 0;
    }

    if(SensorValue(middle) > threshold)
    {

    motor[frontright] = 60;
    motor[backright] = 60;
    motor[frontleft] = 60;
    motor[backLeft] = 60;
    }

    if(SensorValue(left) > threshold)
    {
    motor[frontright] = 0;
    motor[backright] = 0;
    motor[frontleft] = 70;
    motor[backLeft] = 70;
    }
   

 }


Fri May 11, 2012 7:57 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: why wont my line tracking code work?
Just press edit on your post, and take a look at the "code" tags that are around the code. Also, make sure that you're copying your whole program, as I see a missed curly bracket. As for your program, try to step through your program like the microcontroller would, seeing when each condition is met. Here's some pseudocode for what it's doing assuming the missed curly bracket goes at the end:
Code:
Do forever{
  if the button is pressed{
    do stuff....
  }
}

Unless you keep button pushed down through the entire program, it will only go forward an turn.

_________________
sudo rm -rf /


Fri May 11, 2012 8:11 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.