If you’re jumping from 0 to 255, that means that your robot has crossed the entire cross section field of one of it’s sensors in-between measurements. This is entirely possible depending on the size of your sensor field and the speed of your robot and how much you’re making course corrections (swerving).
The solution to this is NOT to blame the environment but to improve the robot. There are a lot of things you can experiment with.
- Test your sensors to see how high above the line they can be and still be accurate. If you can increase the height you’ll increase the area the sensor is getting it’s input from.
- Experiment with the pattern of your sensors. For examples five sensors in the following pattern.
provide a lot more feedback than three sensors side by side. It even be that three sensors patterned
may provide much more overlap and accuracy although I suspect that your robot is moving too fast for such a pattern to be efficient.
Another possible pattern would be:
If the front sensor (array) is on the line, your bot can go faster, when the front sensor loses the line, the bot knows it has a turn coming and should slow down and focus it’s efforts on the back sensors.
Or maybe you feel the need for speed. If so:
will allow you to have gone far off the line and still correct your direction and speed.
- Look at your software. Your controller can only do so many operations per second. The more things that controller has to do, the less it’s looking at the sensor. If it’s spending time performing operations that it doesn’t need to do while moving then it’s wasting cycles.
Note that many of these things are at cross purposes, for example, the more sensors you have and the more complicated the routines you have for analyzing them, the less frequently you’re going to poll any one sensor.
All of these things involve creating experiments, testing, and learning the strengths and limitations of the equipment far beyond what’s in the PDF files.
Some things people may want to try, just to see what happens.
- Can you use additional sensors to increase the illumination of an area but only poll a single sensor mounted higher above the surface?
- Would is be beneficial to mount your sensor at an angle to change the shape of the area it’s looking at, especially if #1 works?
- Do you have enough light to use the light sensors instead of the IR line followers?