Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation Arduino Library for the Pololu QTR Reflectance Sensors 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Library Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. PololuQTRSensors Methods & Usage Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation 1. Introduction QTR-1RC reflectance sensor. QTR-8A reflectance sensor array. The Pololu QTR reflectance sensors carry infrared LED and phototransistor pairs that can provide analog measurements of IR reflectance, which makes them great for close-proximity edge detection and line-following applications. The modules come as compact, single-sensor units (QTR-1A [http://www.pololu.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation 2. Library Installation Note: If you currently have an older version of our QTR reflectance sensor libraries, your first step should be to delete the PololuQTRSensors directory from your arduino-0011/hardware/libraries directory. If you don’t perform this step, the newer version of the libraries might not get compiled.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation 3. PololuQTRSensors Methods & Usage Notes 3.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation PololuQTRSensor Methods Complete documentation of this library’s methods can be found in Section 11 of the Pololu AVR Library Command Reference [http://www.pololu.com/docs/0J18]. For QTR-xA sensors, you will want to instantiate a PololuQTRSensorsAnalog object, and for QTR-xRC sensors you will want to instantiate a PololuQTRSensorsRC object.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation Usage Notes Calibration This library allows you to use the calibrate() method to easily calibrate your sensors for the particular conditions it will encounter. Calibrating your sensors can lead to substantially more reliable sensor readings, which in turn can help simplify your code since. As such, we recommend you build a calibration phase into your application’s initialization routine.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation void loop() { unsigned int sensors[3]; // get calibrated sensor values returned in the sensors array, along with the line position // position will range from 0 to 2000, with 1000 corresponding to the line over the middle sensor int position = qtr.readLine(sensors); // if all three sensors see very low if (sensors[0] > 750 && sensors[1] > { // do something.
Arduino Library for the Pololu QTR Reflectance Sensors © 2001–2009 Pololu Corporation lastError = error; // M1 and M2 are base motor speeds. That is to say, they are the speeds the motors should // spin at if you are perfectly on the line with no error. If your motors are well matched, // M1 and M2 will be equal. When you start testing your PID loop, it might help to start with // small values for M1 and M2. You can then increase the speed as you fine-tune your // PID constants KP and KD.