I try to use Arduino Library for the Pololu QTR Reflectance Sensors. But i could not understand something very well.
Calibrate function is working. OK… i can see minimum and maximum values in serial monitor. when i read position information,it is not like the pdf document. in the pdf document say that
readLine function returns an estimated position of the line. The estimate is made using a weighted average of the sensor indices multiplied by 1000, so that a return value of 0 indicates that the line is directly below sensor 0 (or was last seen by sensor 0 before being lost), a return value of 1000 indicates that the line is directly below sensor 1, 2000 indicates that it’s below sensor 2, etc.
I am using 6 sensors and i read the position like my attachment. how can it possible like this?
Sorry my english, i hope that you can understand my problem?
[code]#include <QTRSensors.h>
#define NUM_SENSORS 6 // number of sensors used
#define NUM_SAMPLES_PER_SENSOR 4 // average 4 analog samples per sensor reading
#define EMITTER_PIN QTR_NO_EMITTER_PIN // emitter is controlled by digital pin 2
// sensors 0 through 5 are connected to analog inputs 0 through 5, respectively
QTRSensorsAnalog qtra((unsigned char) {0, 1, 2, 3, 4, 5},NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];
void setup()
{
delay(500);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // turn on Arduino’s LED to indicate we are in calibration mode
for (int i = 0; i < 400; i++) // make the calibration take about 10 seconds
{
qtra.calibrate(); // reads all sensors 10 times at 2.5 ms per six sensors (i.e. ~25 ms per call)
}
digitalWrite(13, LOW); // turn off Arduino’s LED to indicate we are through with calibration
Serial.begin(9600);
}
void loop()
{
unsigned int position = qtra.readLine(sensorValues);
for (unsigned char i = 0; i < NUM_SENSORS; i++)
{
Serial.print(sensorValues[i]);
Serial.print(’\t’);
}
Serial.println(position);
delay(250);
}[/code]