In this video we are showing how to use two light sensors to do basic aligning on a black line. This is always needed at the competitions. We also show an example for following a line with two sensors.
- 16 Feb 2013
- LEGO MINDSTORMS, LEGO MINDSTORMS NXT
- Align, Line follow, FIRST LEGO League, Line follow, NXT-G, Nxt, Light and Color Sensor, FLL
Find an even IMPROVED version of aligning at How to tutorial 29 where you would learn how to build a block for aligning to a line.
For building instructions of the robot used in the tutorial refer to Episode 13.
- Allign on black line using two light sensors;
- Follow black line using two light sensors.
Today I will show you how to make your robot align perpendicular to a black line. Lets assume we are using the construction we build earlier and the left sensors is connected to PORT 2 and the right sensor to PORT 3 as well as the left motor is connected to PORT B and the right sensor is connected to PORT C. We will take a movement block and set motor B to go Unlimited till the light sensor connected to port 3, detects a black line. We change the expected value to 39 so when the sensors detects a value below 39 we will know it is above a black line. Now we do the same with MOTOR C but in parallel to motor B. We set motor C to unlimited and we set the light sensor on PORT 2 to detect values below 39. If any of the two sensors detects a black line the corresponding motor should stop so we will add a stop block after each sensor. Now our program is ready and we can test it. - video I have shown you how to follow a black line using one sensor, but now I will show you how to do it using two light sensors. We will start with a loop, because we will be constantly repeating the program. We have a Switch block using the light sensor that is connected on PORT 2 and set for threshold value of 39. If the light sensor on PORT 2 sees a black line we have to move MOTOR B, in order to go away from the black line. Our step will be 30 degrees in order to be more precise. If the light sensor doesn't detect a black line we can take another switch, for a light sensor which is connected on PORT 3, set the threshold to 39 and now if the light sensor on port 2 doesn't see a black line and the one on PORT 3 sees, we have to move MOTOR C 30 degrees. If both don't see a black line we move them 30 degrees forward. And this is our program. We download it and test it.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons