I want to know if there’s a way of calibrating the sensors for different shades like, white, gray and black, instead of just the max and min values.
I’m a beginner at programming, and I’m using an Arduino for my line-following robot.
I want to calibrate the sensors as usual, but then I want to calibrate them again for a different shade so it detects it’s crossing a marker. I know I could just test and check the values I get from the marker and put it in the code, but I want my robot to be able to adapt for every situation.
It sounds like you are using our Arduino library for the QTR reflectance sensors and sensor arrays. If so, there are many ways you can go about doing something like that with the QTRSensors library. Since you are new to programming, instead of trying to modify the library, it might be easier defining two
QTRSensorsAnalog objects in your code to store the calibration minimum and maximum values for each line and surface color combination. Then you can compare your sensor reading to those calibrated values. I suggest looking at the “QTRSensors Methods & Usage Notes” section in the Arduino Library for the Pololu QTR Reflectance Sensors guide, particularly the description for
calibrate. Also, you might find it helpful to look at the QTRAExample.ino, which can be found under the examples folder on the QTRSensors library’s GitHub page.
If you run into some trouble getting your code to work, you can post your entire code here along with a description of the expected and actual behavior of your robot, and I would be happy to take a look.
I didn’t know I could create 2 objects for the same device! I’m learning already!
The marker I mentioned is a strip of silver tape, which crosses the standard black line, marking the end of the course. So, every time I would find a crossing, I would check if the values are equivalent to those of the first calibration, and if not, I’d check for the second.
Thanks, Amanda! I’ll return with my results later.