QTR-8A Reflectance Sensors

My group has decided to use the above mentioned sensor for a path following vehicle.

I am having difficulty trying to figure out how to use the sensors as an input by charging all of them up and discharging them using the same 8 pins from the micro controller I am using.

From what I’ve read is that I would need to charge the capacitors up and then calculate the time they take to discharge and accordingly i’ll know whether the sensors are detecting a white line or the black road.

I wanted to know:

  1. How do I charge the capacitors for let’s say 10ms without using extra pins from the micro controller?

  2. What should be my sampling time?

  3. How long is the discharge time if the sensor is sensing white line and how long is it when the sensor is sensing the black road?

I am using ATMEL AT89C55WD chip which is compatible with 8051 micro processor.

A quick reply would be highly appreciated. Thanks in advance.


  1. Use a single pin that can be set to an output first (10 us should be enough!), then an input. Do you know how to do that on your microcontroller?

  2. What do you mean by “sampling time”?

  3. The range of values you get from white to black could be something like 100-1000us. But you have to calibrate it for your particular configuration.



I’m a little confused. Your thread subject is QTR-8A, but your talk of charging the capacitor makes it sound like you have the QTR-8RC. Which board do you have? If you have the QTR-8A, there is no capacitor to charge and no discharge time to measure; you just connect the output to an analog input and read the voltage.

Have you seen our QTR reflectance sensor application note? If you are using the QTR-8RC, this should help answer your second and third questions. The detailed answer to your first question is dependent on the microcontroller you’re using, but the general strategy, as paul said, is to use a single pin that you first set to a driving-high output for 10us and then change to a high-impedance input while measuring the discharge time.

- Ben