|
Page 1 of 1
|
[ 8 posts ] |
|
| Author |
Message |
|
ebille69
Rookie
Joined: Tue Mar 01, 2011 6:16 pm Posts: 21
|
 Line tracking problems
Hy friends, Im trying to use the light sensor for tracking a black line, but i need a code for make the robot stop in the middle of the line, and continue another command. I tryid all but the robot ever is going till the end of the line... and is not doing the other commando.
|
| Tue Sep 13, 2011 2:45 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Line tracking problems
I am not sure what your program is trying to do from the code. What do all the motor commands at the start do? What are you expecting the code at the bottom to do?
Can you explain your code to me? That might help me better understand.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Sep 13, 2011 3:31 pm |
|
 |
|
ebille69
Rookie
Joined: Tue Mar 01, 2011 6:16 pm Posts: 21
|
 Re: Line tracking problems
Okay, thanks. The first code from " {" to the begining of the light sensor code makes the robot move from the base of the " body forward, you know that right? " to one bone, then the robot begans reading with the light sensor, if it read white it goes left, and if it read black it goes right, so when he detects a black line, it goes left and right following it. And what im looking for is, how i can do for make the robot stop in the middle of the black line, i mean how to stop de robot? for make the robot do another command.With this code, the robot goes till the end without stoping.
Thank you Xander.
|
| Wed Sep 14, 2011 1:54 am |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 Re: Line tracking problems
How do you want the robot to know when it has reached the middle of the line? Do you want to use encoders or just time it?
_________________ sudo rm -rf /
|
| Wed Sep 14, 2011 7:46 am |
|
 |
|
ebille69
Rookie
Joined: Tue Mar 01, 2011 6:16 pm Posts: 21
|
 Re: Line tracking problems
It doesn't matter, but i prefer timing it. thanks
|
| Thu Sep 15, 2011 10:33 am |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 Re: Line tracking problems
instead of doing while(true), you can try this:
_________________ sudo rm -rf /
|
| Thu Sep 15, 2011 6:52 pm |
|
 |
|
ebille69
Rookie
Joined: Tue Mar 01, 2011 6:16 pm Posts: 21
|
 Re: Line tracking problems
Thanks! One question, IF i wanna write another program/code, after the light's sensor timer get finished, where i have to write it? thanks
|
| Fri Sep 16, 2011 5:23 pm |
|
 |
|
vnguyen
Site Admin
Joined: Wed Jan 24, 2007 10:44 am Posts: 421 Location: Pittsburgh, PA
|
 Re: Line tracking problems
The robot basically reads the commands from left to right, going from the top to the bottom... like a human would read a book. So basically, if you want your robot to track a line for a certain amount of time, you use that while loop. Once it's done (as indicated by the closing curly brace, "}") it will continue to the next line of code. So if you want it to perform another behavior after the line tracking, you would put it after the closing brace of the while loop (BUT BEFORE the closing brace of your program).
_________________Vu Nguyen Software Training Development Team | WebmasterNeed more support? Use the ROBOTC Ticketing systemRobotc.net| Robomatter Store | Robotics Academy
|
| Fri Sep 16, 2011 10:25 pm |
|
|
|
Page 1 of 1
|
[ 8 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 5 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
|
|