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.
