View Single Post
  #22   Spotlight this post!  
Unread 16-02-2004, 13:47
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Newbie Autonomous Question(s)

Quote:
Originally Posted by LBK Rules
Our team has been trying to code the banners, and we just can't get it to work right.

If somebody can please post some working line fowolling code, I know all of us newbies woud greatly appreciate it.
Well, I can't guarrantee this works, but if you want to look at it...
PHP Code:
// Check if the right sensor is reading the line
if(lineDetectorLeft == ON_LINE)
{
  
// Turn right
  
driveMotorLeft 127;
  
driveMotorRight 254;
}
else if(
lineDetectorRight == ON_LINE)
{
  
// Turn left
  
driveMotorLeft 254;
  
driveMotorRight 127;
}
else
{
  
// Go forward
  
driveMotorLeft 254;
  
driveMotorRight 254;

Subsitute pwmXX for the driveMotorLeft and Rights, the lineDetectorLeft and Rights with the digital inputs they are on, and the ON_LINEs with the value that the sensors read when over the line. This is a very simple algorithm and can be improved, but it gives you the idea. Put it in its own function and continually call it and it will (should) faithfully follow a line.

--EDIT--
You can also adjust the speeds passed to the motors. The way it is now, it might lose the line because it is too fast.
__________________


Last edited by Ryan M. : 16-02-2004 at 13:51.