5.g. Pololu3pi - Sensor Library for the 3pi Robot


This library allows you to easily interface with the five infrared reflectance sensors on the 3pi robot. Note that in order to use this library, you must also include PololuQTRSensors.h in your sketch. You should have something like the following at the top of your sketch:

#include <Pololu3pi.h>  // gives access to sensor interface functions
#include <PololuQTRSensors.h>  // used by Pololu3pi.h
#include <OrangutanMotors.h>  // gives access to motor control functions
#include <OrangutanBuzzer.h>  // gives access to buzzer control functions

Unlike the other Orangutan libraries, you must explicitly call the init() method to initialize your Pololu3pi object before using it.

All of the methods in this class are static; you should never have more than one instance of a Pololu3pi object in your sketch.

Pololu3pi Methods

Complete documentation of this library’s methods can be found in Section 19 of the Pololu AVR Library Command Reference.

Usage Examples

This library comes with three example sketches that you can load by going to File > Examples > Pololu3pi. There is a simple line-following example, a more advanced PID-based line-following example, and a basic maze-solving example.


For more information on creating line and maze courses, as well as a detailed explanation of the C versions of the demo programs, please see sections 6 and 7 of the 3pi User’s Guide.