View unanswered posts | View active topics It is currently Mon Sep 21, 2020 4:20 pm

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
why wont my line tracking code work?
Author Message
Rookie

Joined: Wed Dec 21, 2011 4:22 pm
Posts: 26
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
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning