AVR Library Command Reference

This constructor performs no initialization. If it is used, the user must call init() before using the methods in this
class.
PololuQTRSensorsRC::PololuQTRSensorsRC(unsigned char* pins, unsigned char numSensors, unsigned int
timeout = 4000, unsigned char emitterPin = 255);
This constructor just calls init(), below.
void PololuQTRSensorsRC::init(unsigned char* pins, unsigned char numSensors, unsigned int timeout =
4000, unsigned char emitterPin = 255)
void qtr_rc_init(unsigned char* pins, unsigned char numSensors, unsigned int timeout, unsigned char
emitterPin)
Initializes a QTR-RC (digital) sensor array.
The array pins contains the (Arduino) pin numbers for each sensor. For example, if pins is {3, 6, 15}, sensor 0 is
on digital pin 3 or PD3, sensor 1 is on digital pin 6 or PD6, and sensor 2 is on digital pin 15 or PC1 (Arduino
analog input 1). Digital pins 0 7 correpsond to port D pins PD0 PD7, respectively. Digital pins 8 13
correspond to port B pins PB0 PB5. Digital pins 14 19 correspond to port C pins PC0 PC5, which are
referred to in the Arduino environment as analog inputs 0 – 5.
numSensors specifies the length of the ‘pins’ array (the number of QTR-RC sensors you are using). numSensors
must be no greater than 8.
timeout specifies the length of time in Timer2 counts beyond which you consider the sensor reading completely
black. That is to say, if the pulse length for a pin exceeds timeout, pulse timing will stop and the reading for that
pin will be considered full black. It is recommended that you set timeout to be between 1000 and 3000 us,
depending on factors like the height of your sensors and ambient lighting. This allows you to shorten the duration
of a sensor-reading cycle while maintaining useful measurements of reflectance. On a 16 MHz microcontroller,
you can convert Timer2 counts to microseconds by dividing by 2 (2000 us = 4000 Timer2 counts = timeout of
4000). On a 20 MHz microcontroller, you can convert Timer2 counts to microseconds by dividing by 2.5 or
multiplying by 0.4 (2000 us = 5000 Timer2 counts = timeout of 5000).
emitterPin is the Arduino digital pin that controls whether the IR LEDs are on or off. This pin is optional and only
exists on the 8A and 8RC QTR sensor arrays. If a valid pin is specified, the emitters will only be turned on during
a reading. If an invalid pin is specified (e.g. 255), the IR emitters will always be on.
PololuQTRSensorsAnalog::PololuQTRSensorsAnalog()
This constructor performs no initialization. If this constructor is used, the user must call init() before using the
methods in this class.
PololuQTRSensorsAnalog::PololuQTRSensorsAnalog(unsigned char* analogPins, unsigned char
numSensors, unsigned char numSamplesPerSensor = 4, unsigned char emitterPin = 255)
This constructor just calls init(), below.
void OrangutanAnalog::init(unsigned char* analogPins, unsigned char numSensors, unsigned char
numSamplesPerSensor = 4, unsigned char emitterPin = 255)
void qtr_analog_init(unsigned char* analogPins, unsigned char numSensors, unsigned char
numSamplesPerSensor, unsigned char emitterPin)
Initializes a QTR-A (analog) sensor array.
The array pins contains the analog pin assignment for each sensor. For example, if pins is {0, 1, 7}, sensor 1 is on
analog input 0, sensor 2 is on analog input 1, and sensor 3 is on analog input 7. The ATmega168 has 8 total
Pololu AVR Library Command Reference © 2001–2009 Pololu Corporation
11. QTR Reflectance Sensors Page 29 of 35