

There are dozens (probably hundreds) of different programs that can be written to help the robot follow a line. Whether the line is straight, curved, or a combination of both, the robot will use a simple formula to determine its position in relation to the line and how it should move in order to stay on the line. Most line following programs utilize some formula for determining if the robot should move to the left, or right, in order to stay on the line. Line Following Methods (Example Programs)
Download robotc code#
The code below is more of a pseudocode than any actual code you can copy-and-paste into your program. The getLightPercent() and getLightPortion() functions below may need to be created by you. Once the condition has been met in the until function, then stop the line following task to stop following the line. The purpose of using a separate task for line following is so you can break from the line following based on the use of existing until functions such as untilSonar(), untilTouch(), untilDistance(), wait(), etc. This exercise walks you through the different steps in setting up a line following task and running it from within the main task. If you have RobotC, here is a good exercise in the task of LineFollowing. Line Following RobotC Include File Exercise in Line Following (for RobotC) A Non-Functioning EV3 (i.e., frozen or dead).
