Hi, I’ve been playing around with my Arduino Uno and a couple of QTR-1RC sensors today, using the QTRSensors library. Everything seemed to be working as expected, but no matter what I put in front of either sensor, the values returned from the sensor are always within a very small range (between 4 and 12, usually 8). The range I’m expecting is 0 - 1000.
The pins were connected to GND, 5V and digital 2.
Here’s my sketch:
#include <QTRSensors.h>
#define SENSOR_PIN 2
QTRSensorsRC qtr((unsigned char[]) {SENSOR_PIN}, 1, 1000);
unsigned int sensorValues[1];
void setup()
{
Serial.begin(9600);
pinMode (SENSOR_PIN, INPUT);
int i;
for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
{
qtr.calibrate();
delay(20);
Serial.println("calibrating");
}
}
void loop()
{
qtr.read(sensorValues);
Serial.print(sensorValues[0]);
if ((sensorValues[0] >= 0) && (sensorValues[0] <= 500))
{
Serial.print(" High Reflectance ");
}
else
{
Serial.print(" Low Reflectance ");
}
Serial.println();
delay(250);
}
Is there anything I’m missing that might be causing the odd results?
Sorry if this question is a duplicate, it wasn’t possible to search for ‘QTR-1RC’.