Question about calibration

I was wondering how I actually calibrate the sensor. I’ve read the libraries and I’ve come up with the following code:

void calibration()
{
for (int i = 0; i < 250; i++)
{
qtrrc.calibrate(QTR_EMITTERS_ON); // (i.e. ~25 ms per call)
delay(20);
}

if (DEBUG)
{

Serial.begin(9600);
for (int i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtrrc.calibratedMinimumOn[i]);
Serial.print(’ ');
}
Serial.println();

for (int i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtrrc.calibratedMaximumOn[i]);
Serial.print(’ ');
}
Serial.println();
Serial.println();
}
}

My question is, what do I actually do physically to the sensors?
Do I put them on black, and then on white?
Do I do this once? Twice? Many?
Should I rotate the sensors above a line?

How do I actually use the DEBUG part of the code?
I’ve run it some times, and it returns some values that are somewhat coherent.
It always takes several seconds, and I just swipe the sensors multiple times over a white line with black background.
I would really like the calibration phase to be as quick as possible.
5 seconds would be nice. How do I achieve this?

Hello.

I suspect you are using one of our QTR reflectance sensors. You can find the answers to most of your questions on how to calibrate the QTR sensors under the “Calibration” heading in the “QTRSensors Methods & Usage Notes” section of the Arduino Library for the Pololu QTR Reflectance Sensors guide. Essentially, you want to move the QTR sensor array over the black and white surfaces so that each sensor on the array records the maximum and minimum values. It might be helpful for you to look at the LineFollower code for the Zumo 32U4 Robot, in particular the function calibrateSensors, to get an idea of how to calibrate your QTR sensors.

With regards to your question about the if-statement, the DEBUG variable must be any non-zero value for the condition statement to evaluate true. I do not know what data type you defined your DEBUG variable as, so I cannot provide a more detailed answer.

- Amanda