AVR Library Command Reference

void qtr_read_calibrated(unsigned int *sensorValues, unsigned char readMode)
Returns sensor readings calibrated to a value between 0 and 1000, where 0 corresponds to a reading that is less
than or equal to the minimum value read by calibrate() and 1000 corresponds to a reading that is greater than or
equal to the maximum value. Calibration values are stored separately for each sensor, so that differences in the
sensors are accounted for automatically.
unsigned int PololuQTRSensors::readLine(unsigned int *sensorValues, unsigned char readMode =
QTR_EMITTERS_ON, unsigned char whiteLine = 0)
void qtr_read_line(unsigned int *sensorValues, unsigned char readMode)
Operates the same as read calibrated, but with a feature designed for line following: this function returns an
estimated position of the line. The estimate is made using a weighted average of the sensor indices multiplied by
1000, so that a return value of 0 indicates that the line is directly below sensor 0, a return value of 1000 indicates
that the line is directly below sensor 1, 2000 indicates that it’s below sensor 2000, etc. Intermediate values
indicate that the line is between two sensors. The formula is:
0*value0 + 1000*value1 + 2000*value2 + ...
--------------------------------------------
value0 + value1 + value2 + ...
As long as your sensors aren’t spaced too far apart relative to the line, this returned value is designed to be
monotonic, which makes it great for use in closed-loop PID control. Additionally, this method remembers where
it last saw the line, so if you ever lose the line to the left or the right, it’s line position will continue to indicate the
direction you need to go to reacquire the line. For example, if sensor 4 is your rightmost sensor and you end up
completely off the line to the left, this function will continue to return 4000.
By default, this function assumes a dark line (high values) surrounded by white (low values). If your line is light
on black, set the optional second argument whiteLine to true. In this case, each sensor value will be replaced by
the maximum possible value minus its actual value before the averaging.
unsigned int* PololuQTRSensors::calibratedMinimumOn
unsigned int* qtr_calibrated_minimum_on()
The calibrated minumum values measured for each sensor, with emitters on. The pointers are unallocated and set
to 0 until calibrate() is called, and then allocated to exactly the size required. Depending on the readMode
argument to calibrate(), only the On or Off values may be allocated, as required. This and the following variables
are made public so that you can use them for your own calculations and do things like saving the values to
EEPROM, performing sanity checking, etc. The calibration values are available through function calls from C.
unsigned int* PololuQTRSensors::calibratedMaximumOn
unsigned int* qtr_calibrated_maximum_on()
The calibrated maximum values measured for each sensor, with emitters on.
unsigned int* PololuQTRSensors::calibratedMinimumOff
unsigned int* qtr_calibrated_minimum_off()
The calibrated minimum values measured for each sensor, with emitters off.
unsigned int* PololuQTRSensors::calibratedMaximumOff
unsigned int* qtr_calibrated_maximum_off()
The calibrated maximum values measured for each sensor, with emitters off.
PololuQTRSensors::~PololuQTRSensors()
The destructor for the PololuQTRSensors class frees up memory allocated for the calibration arrays. This feature
is not available in C.
PololuQTRSensorsRC::PololuQTRSensorsRC()
Pololu AVR Library Command Reference © 2001–2009 Pololu Corporation
11. QTR Reflectance Sensors Page 28 of 35