Support » Arduino Library for the Pololu QTR Reflectance Sensors »
1. Introduction
<p class="note_warning">This guide is for an older version of the QTRSensors Arduino library (3.1.0). The current version of the library can be found <a href="https://github.com/pololu/qtr-sensors-arduino">on GitHub</a>, and its documentation is <a href="http://pololu.github.io/qtr-sensors-arduino/">here</a>.</p>
<!-- table(side_by_side_pics).
|<table class="picture_with_caption center"><tr><td style="max-width: 160px"><img alt="" class="" data-gallery-pictures="[{"id":"0J4428","caption":"\u003cp\u003eQTR-L-1A reflectance sensors.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J4428.98x98.jpg?b754854c94f6723103f6c20d033e364e","url_medium":"https://a.pololu-files.com/picture/0J4428.600x480.jpg?b754854c94f6723103f6c20d033e364e","url_full":"https://a.pololu-files.com/picture/0J4428.1200.jpg?b754854c94f6723103f6c20d033e364e","longest_side":800}]" data-picture-id="0J4428" data-picture-longest_side="800" src="https://a.pololu-files.com/picture/0J4428.160.jpg?b754854c94f6723103f6c20d033e364e" /></td></tr><tr><th style="max-width: 160px"><p>QTR-L-1A reflectance sensors.</p></th></tr></table>|<table class="picture_with_caption center"><tr><td style="max-width: 180px"><img alt="" class="" data-gallery-pictures="[{"id":"0J625","caption":"\u003cp\u003eQTR-1RC reflectance sensor.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J625.98x98.jpg?e821a1f5ecbf3a8e8f74d08e3343dbfa","url_medium":"https://a.pololu-files.com/picture/0J625.600x480.jpg?e821a1f5ecbf3a8e8f74d08e3343dbfa","url_full":"https://a.pololu-files.com/picture/0J625.1200.jpg?e821a1f5ecbf3a8e8f74d08e3343dbfa","longest_side":677}]" data-picture-id="0J625" data-picture-longest_side="677" src="https://a.pololu-files.com/picture/0J625.180.jpg?e821a1f5ecbf3a8e8f74d08e3343dbfa" /></td></tr><tr><th style="max-width: 180px"><p>QTR-1RC reflectance sensor.</p></th></tr></table>|
<table class="picture_with_caption center"><tr><td style="max-width: 150px"><img alt="" class="" data-gallery-pictures="[{"id":"0J615","caption":"\u003cp\u003eQTR-8A reflectance sensor array.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J615.98x98.jpg?ef5903b25450c25de151ed9b43d1fce3","url_medium":"https://a.pololu-files.com/picture/0J615.600x480.jpg?ef5903b25450c25de151ed9b43d1fce3","url_full":"https://a.pololu-files.com/picture/0J615.1200.jpg?ef5903b25450c25de151ed9b43d1fce3","longest_side":800}]" data-picture-id="0J615" data-picture-longest_side="800" src="https://a.pololu-files.com/picture/0J615.150.jpg?ef5903b25450c25de151ed9b43d1fce3" /></td></tr><tr><th style="max-width: 150px"><p>QTR-8A reflectance sensor array.</p></th></tr></table>| | --><table class="picture_with_caption center"><tr><td style="max-width: 400px"><a href="https://a.pololu-files.com/picture/0J4642.1200.jpg?9ae24a3959a88fee8dd66d333023e2dc" class="noscript-fallback"><img alt="" class="zoomable" data-gallery-pictures="[{"id":"0J4642","caption":"\u003cp\u003eQTR sensor size comparison. Top row: QTRX-HD-07, QTR-HD-07; middle row: QTR-3, QTR-1, QTR-L-1; bottom row: QTR-8.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J4642.98x98.jpg?9ae24a3959a88fee8dd66d333023e2dc","url_medium":"https://a.pololu-files.com/picture/0J4642.600x480.jpg?9ae24a3959a88fee8dd66d333023e2dc","url_full":"https://a.pololu-files.com/picture/0J4642.1200.jpg?9ae24a3959a88fee8dd66d333023e2dc","longest_side":934}]" data-picture-id="0J4642" data-picture-longest_side="934" src="https://a.pololu-files.com/picture/0J4642.400.jpg?9ae24a3959a88fee8dd66d333023e2dc" /></a></td><p></tr><tr><th style="max-width: 400px"><p>QTR sensor size comparison. Top row: QTRX-HD-07, QTR-HD-07; middle row: QTR-3, QTR-1, QTR-L-1; bottom row: QTR-8.</p></th></tr></table></p>
<p>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 (<a href="/product/2458">QTR-1A</a> and <a href="/product/2459">QTR-1RC</a>; <a href="/product/2454">QTR-L-1A</a> and <a href="/product/2455">QTR-L-1RC</a>), 3-sensor arrays (<a href="/product/2456">QTR-3A</a> and <a href="/product/2457">QTR-3RC</a>), or as 8-sensor arrays (<a href="/product/960">QTR-8A</a> and <a href="/product/961">QTR-8RC</a>) that can be optionally split into a 2-sensor array and a 6-sensor array.</p>
<p>The modules are available in two different output formats: the QTR-xA outputs an analog voltage between 0 and Vcc that can be measured by an analog-to-digital converter (ADC), and the QTR-xRC outputs require a digital I/O line capable of driving the output line high and then measuring the time for the output voltage to decay (which provides an analog measurement of reflectance).</p>
<table class="side_by_side_pics">
<tr>
<td><table class="picture_with_caption center"><tr><td style="max-width: 200px"><img alt="" class="" data-gallery-pictures="[{"id":"0J4433","caption":"\u003cp\u003eQTR-L-1A reflectance sensor schematic diagram.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J4433.98x98.jpg?e738d61d87595c2b0ece249fc21fb152","url_medium":"https://a.pololu-files.com/picture/0J4433.600x480.jpg?e738d61d87595c2b0ece249fc21fb152","url_full":"https://a.pololu-files.com/picture/0J4433.1200.png?e738d61d87595c2b0ece249fc21fb152","longest_side":300}]" data-picture-id="0J4433" data-picture-longest_side="300" src="https://a.pololu-files.com/picture/0J4433.200.jpg?e738d61d87595c2b0ece249fc21fb152" /></td></tr><tr><th style="max-width: 200px"><p>QTR-L-1A reflectance sensor schematic diagram.</p></th></tr></table></td>
<td><table class="picture_with_caption center"><tr><td style="max-width: 200px"><img alt="" class="" data-gallery-pictures="[{"id":"0J630","caption":"\u003cp\u003eQTR-1A reflectance sensor schematic diagram.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J630.98x98.jpg?0338402f14f65ad38bf92790ff6b2cde","url_medium":"https://a.pololu-files.com/picture/0J630.600x480.jpg?0338402f14f65ad38bf92790ff6b2cde","url_full":"https://a.pololu-files.com/picture/0J630.1200.png?0338402f14f65ad38bf92790ff6b2cde","longest_side":300}]" data-picture-id="0J630" data-picture-longest_side="300" src="https://a.pololu-files.com/picture/0J630.200.jpg?0338402f14f65ad38bf92790ff6b2cde" /></td></tr><tr><th style="max-width: 200px"><p>QTR-1A reflectance sensor schematic diagram.</p></th></tr></table></td>
</tr>
</table>
<table class="picture_with_caption center"><tr><td style="max-width: 200px"><img alt="" class="" data-gallery-pictures="[{"id":"0J631","caption":"\u003cp\u003eQTR-1RC and QTR-L-1RC reflectance sensor schematic diagram.\u003c/p\u003e","url_tiny":"https://a.pololu-files.com/picture/0J631.98x98.jpg?ae9455b459ff6470ff8055966838a530","url_medium":"https://a.pololu-files.com/picture/0J631.600x480.jpg?ae9455b459ff6470ff8055966838a530","url_full":"https://a.pololu-files.com/picture/0J631.1200.png?ae9455b459ff6470ff8055966838a530","longest_side":300}]" data-picture-id="0J631" data-picture-longest_side="300" src="https://a.pololu-files.com/picture/0J631.200.jpg?ae9455b459ff6470ff8055966838a530" /></td><p></tr><tr><th style="max-width: 200px"><p>QTR-1RC and QTR-L-1RC reflectance sensor schematic diagram.</p></th></tr></table></p>
<p>Please see the <a href="/category/123/pololu-qtr-reflectance-sensors">product pages</a> for more information on how these sensors work.</p>
<p>This document will explain how to install Arduino libraries for the Pololu QTR reflectance sensors, and it will provide sample sketches as well as links to library documentation. The libraries will give you everything you need to interface with a QTR-8x reflectance sensor array or multiple QTR-1x reflectance sensors, including advanced features like automatic calibration and, in the case of line detection, calculation of the line’s position.</p>