# Problem with the qtr-8a sensor

**URL:** https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954
**Category:** Electronics
**Created:** [July 3, 2025, 6:21pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954 "2025-07-03T18:21:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dimitris\_Mavrakis](https://forum.pololu.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@Dimitris\_Mavrakis](https://forum.pololu.com/u/Dimitris_Mavrakis)
#### Post date: [July 3, 2025, 6:21pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/1 "2025-07-03T18:21:47Z")

</div>

Hello, I am building a line following robot, using the qtr-8a sensor and the arduino nano as the brain of the robot. For some tests I only connect the first and last sensor with the analog pins of the arduino and I have the following problems:

1. Sometimes the values I get seem random. They might get to 0, then 400, then 800 and finally to 1023.
2. The values I get change over 100 units + or -, although I don’t move the sensor at all.
3. The sensors don’t have really different values when I put them on different color surfaces (white and black)
4. When I try to calibrate them the values on white surfaces are around 990 and on black 1000, and when I don’t calibrate the values don’t change that much no matter the surface.

I have a competition on Sunday, so I need help as soon as possible. Don’t afraid to ask for images or any additional information.  
PS: I have connected the 5v of the arduino nano with the VCC, the LEDON with the GND and the GND with the GND.

---

<div class="post-metadata">

### Author: ![bidrohini](https://forum.pololu.com/letter_avatar_proxy/v4/letter/b/ecae2f/32.png) [@bidrohini](https://forum.pololu.com/u/bidrohini)
#### Post date: [July 3, 2025, 6:33pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/2 "2025-07-03T18:33:38Z")

</div>

The connection should be

| QTR-8A Pin | Arduino Nano Pin |
| --- | --- |
| VCC | 5V |
| GND | GND |
| LEDON | leave unconnected (or connect to VCC for always-on LEDs) |
| A0–A7 | Any analog pin |
| If you connect `LEDON` to `GND`, the **IR LEDs turn off** , which explains: | |

Random readings, almost no difference between white and black and calibration failing.  
Disconnect LEDON from GND. Either leave LEDON unconnected or connect it to 5V to force LEDs on.

---

<div class="post-metadata">

### Author: ![Dimitris\_Mavrakis](https://forum.pololu.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@Dimitris\_Mavrakis](https://forum.pololu.com/u/Dimitris_Mavrakis)
#### Post date: [July 3, 2025, 7:08pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/3 "2025-07-03T19:08:03Z")

</div>

Thank you for the reply!  
The problem doesn’t seem to get fixed… In addition now, the values of the sensor are like a pulse. It starts with a lot of 0s then goes to the 200s, 400s then 1023, again 400s, 200s and a lot of zeros again.  
Here is an example of what I see:  
0  
0  
0  
0  
0  
0  
120  
250  
480  
740  
1023  
800  
460  
210  
100  
0  
0  
0  
0  
0  
0

---

<div class="post-metadata">

### Author: ![BrandonM](https://forum.pololu.com/user_avatar/forum.pololu.com/brandonm/32/609_2.png) [@BrandonM](https://forum.pololu.com/u/BrandonM)
#### Post date: [July 3, 2025, 10:10pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/4 "2025-07-03T22:10:08Z")

</div>

Hello.

As bidrohini mentioned, I recommend leaving the LEDON pin disconnected unless you specifically want to turn it off when not using the sensor to save power.

Can you try running the [QTRARawValuesExample](https://github.com/pololu/qtr-sensors-arduino/blob/master/examples/QTRARawValuesExample/QTRARawValuesExample.ino) from our QTR library and posting the output you get from that when the sensors are over a white surface then a black one? You will need to modify the SensorCount value and the pins used in the `qtr.setSensorPins()` function to match your setup.

Also, could you post some pictures of your setup that show all of your connections?

Brandon

---

<div class="post-metadata">

### Author: ![Dimitris\_Mavrakis](https://forum.pololu.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@Dimitris\_Mavrakis](https://forum.pololu.com/u/Dimitris_Mavrakis)
#### Post date: [July 4, 2025, 7:58am UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/5 "2025-07-04T07:58:37Z")

</div>

Hello Brandon,  
Thank you for your reply!  
Using the QTRARawValuesExample I get these values when the sensor is on white:  
 ![image](https://forum.pololu.com/uploads/default/original/2X/e/ed4a617065a4393aaab3c48a5f9390698e6f2974.png)  
And on black:  
 ![image](https://forum.pololu.com/uploads/default/original/2X/e/e89a65e44fdae19bd192571fc3e88850c7afd81b.png)  
These are some pictures of my setup:

 ![image](https://forum.pololu.com/uploads/default/original/2X/8/80d9a724501351193fc0817d7bd2b8f9b8cd2489.jpeg)  
 ![image](https://forum.pololu.com/uploads/default/original/2X/1/19821162ebef14fa5cc463ddac8818301b42baa0.jpeg)  
 ![image](https://forum.pololu.com/uploads/default/original/2X/e/e85dde6f2659727b0778d2aee68cb1e34b6a3cd3.jpeg)

---

<div class="post-metadata">

### Author: ![BrandonM](https://forum.pololu.com/user_avatar/forum.pololu.com/brandonm/32/609_2.png) [@BrandonM](https://forum.pololu.com/u/BrandonM)
#### Post date: [July 7, 2025, 8:00pm UTC](https://forum.pololu.com/t/problem-with-the-qtr-8a-sensor/27954/6 "2025-07-07T20:00:54Z")

</div>

Those readings look fine; could you try running the [QTRAExample](https://github.com/pololu/qtr-sensors-arduino/blob/master/examples/QTRAExample/QTRAExample.ino) (which uses calibrated values) and post the output? Please make sure to pass each sensor over the white and black surfaces multiple times during the calibration phase.

Brandon
