User Manual
Example usage:
unsigned int sensor_values[5];
read_line_sensors(sensor_values);
void Pololu3pi::emittersOn()
void emitters_on()
Turn the IR LEDs on. This is mainly for use by read_line_sensors(), and calling this function before or after
the reading the sensors will have no effect on the readings, but you may wish to use it for testing purposes.
void Pololu3pi::emittersOff()
void emitters_off()
Turn the IR LEDs off. This is mainly for use by read_line_sensors(), and calling this function before or after
the reading the sensors will have no effect on the readings, but you may wish to use it for testing purposes.
void Pololu3pi::calibrate(unsigned char readMode = IR_EMITTERS_ON)
void calibrate_line_sensors(unsigned char readMode)
Reads the sensors for calibration. The sensor values are not returned; instead, the maximum and minimum
values found over time are stored internally and used for the readLineSensorsCalibrated() method.
void Pololu3pi::readLineSensorsCalibrated(unsigned int *sensorValues, unsigned char readMode =
IR_EMITTERS_ON)
void read_line_sensors_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 Pololu3pi::readLine(unsigned int *sensorValues, unsigned char readMode =
IR_EMITTERS_ON, unsigned char whiteLine = 0)
unsigned int read_line(unsigned int *sensorValues, unsigned char readMode)
unsigned int read_line_white(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 will 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, its line position will continue to indicate the
direction you need to go to reacquire the line. For example, since sensor 4 is your rightmost sensor, if 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 or call read_line_white(). In this case, each
sensor value will be replaced by the maximum possible value minus its actual value before the averaging.
unsigned int* Pololu3pi::getLineSensorsCalibratedMinimumOn()
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
19. 3pi Robot Functions Page 64 of 65