Lego
MINDSTORMS NXT
Basic Line Follow Step By Step Directions
| Loop(forever) if LightValue < 40 LeftMotor Power = 40 RightMotor Power = 0 if LightValue > 40 RightMotor Power = 40 LeftMotor Power = 0 |
| Robot
Project 1b: Basic Line Follow Objectives: Use Conditional Switch Block to evaluate Input Values of Light Sensor Use Loop Block to Repeat Switch Block Project: Write an NXT-G program that will have your robot follow a line using a simple Algorithm. Process: 1. Open the Mindstorms NXT-G software. (Double click the orange square icon.) ![]() 2. Name your program "LastnameBasicLineFollow" and Click "GO." 3. Drag a Switch Block to the Programming Area. a. Set the Sensor to "Light Sensor" b. Set the Compare to < 40. ![]() ![]() 4. Drag a Motor Block to top inside of the Switch Block ![]() 5. Set the Motor Block Parameters to: a. Motor Selection = C b. Power = 40 c. Duration = Unlimited ![]() 6. Drag another Motor Block and put it on the top inside of the Switch Block. ![]() 7. Set the Motor Block Parameters to: a. Motor Selection = B b. Direction = Stop ![]() 8. Drag another Motor Block and put it on the bottom inside of the Switch Block. ![]() 9. Set the Motor Block Parameters to: a. Motor Selection = B b. Power = 40 c. Duration = Unlimited ![]() 10. Drag another Motor Block and put it on the bottom inside of the Switch Block. ![]() 11. Set the Motor Block Parameters to: a. Motor Selection = C b. Direction = Stop ![]() 12. Drag a Loop Block into the programming area place it to the left of the Switch Block. ![]() 13. Drag the Switch Block inside the Loop Block. ![]() 14. Save Program. (File -> Save) 15. Download and test with the Robot. Notes: A. You will need to work with the Light Value Numbers and Motor Speeds to "tune" the line follow to track the line depending on light conditions and path of line. A lower motor speed will allow the robot to track a "more curvy" line. B. This program will track the Right Hand side of the line. How can you change the program to track the Left Hand side of the line? C. The robot makes a wiggly track to follow the line. How can you modify the program to allow for more efficient motion with the Robot. |