I’m currently working on a project that involves line following using the QTR-8RC sensor with an Arduino Mega 2560. I’m currently using the PID following code from this post: PID based Line Following using Pololu QTR-8RC Sensors
What I’m curious is how can I tell the robot to stop if the sensors read a solid black line so that I can tell the robot to perform an operation?
You might find it helpful to look at MazeSolver.ino for the Zumo robot for Arduino, particularly this line of code, where it checks for the ending spot where the four middle sensor values are all above a specific threshold.
Thank you for the reply Amanda.
However, I’m not entirely sure how to utilize this code?
I’m assuming of course i need to define ABOVE_LINE and SENSOR_THRESHOLD as thye have donw in the code but do I require using the Zumo Library for this? As I am using the QTR-8RC and not a Zumo sensor array?
Is there some way I can simply read the raw values from the sensor and get it to stop that way??
You do not have to copy that code or use the Zumo library. The purpose of pointing you to that part of the Zumo MazeSolver example code was to give you an idea of how you can read the individual values in the sensor array, compare them to a minimum threshold indicating that the sensor sees a black surface, then verify that all sensors see a black surface before commanding your robot to stop and do something else.
It might be better for you to look at the QTRA examples in the Arduino QTRSensors library to understand how to extract the sensor values from the an array. To just read the raw values, run QTRARawValuesExample.ino.