I am building a PID based line follower. I am using arduino uno, QTR-8RC (although using only five sensors ), L293D motor driver, DC motors 3S LiPo.
The problem is "The problem statement consist of both White line on black background and black line on white background on same track I am trying to solve it but could found a way. Can you guys suggest anything?
Also when it finds GAP or say what does readLine return when it finds GAP in track ?
Any help will be appreciated.
If you are using our QTR libraries, you can take advantage of our
readLine() function, which has an optional boolean argument,
whiteLine, that allows the sensors to detect either a black line on a white surface or a white line on a black surface. We do not have any specific code that would allow you to notice both track types for a given course, but you could likely be creative about using that method to figure something out.
You can find an example that shows how to switch the QTR code from detecting a black line on a white surface (which is the default) to detect a white line on a black surface in this post.
As for detecting gaps, (which I assume you mean are areas of identical color/reflectance underneath all of your QTR sensors for a given part of the course, whether all black or all white), I do not recommend using the position variable that gets updated when you call
readLine(). I do not think that it would give reliable results when the line suddenly disappears from the middle of the sensor bar. Instead, it would probably be better to read the individual sensor values from the array that is also updated, which should return similar values for each sensor if the sensors are facing the same kind of surface. You might also find it helpful to look at how our Zumo maze solving code determines when it is at an intersection or the end of the maze.