I have the Arduino Mega and just bought from Pololu the QTR-8RC array and like some others here I am getting all zeros all the time. I have never seen a solution to this problem. My code is simple and right from this site. Since the QTR-8RC is suppose to be digital, I am connecting 5 of the 8 outputs (just to test it out) to digital pins 44, 46, 48, 50 and 52 on the Mega. When I run the program I get 0 0 0 0 0 always. I connected a scope to one of the pins and I see no activity on the pin so I am wondering if the software library works with the Ardiuno Mega. I am using the digital pins for other functions and they work well. Any ideas? The code is attached.
#include <PololuQTRSensors.h>
PololuQTRSensorsRC qtr((unsigned char[]) {44,46,48,50,52}, 5); //digital pins
void setup()
{
Serial.begin(9600);
int i;
for (i = 0; i < 250; i++) // make the calibration take about 5 seconds
{
qtr.calibrate();
delay(20);
}
}
void loop()
{
unsigned int sensors[5]; // change 6 to whatever number of sensors you are using
int position = qtr.readLine(sensors);
// output to Serial monitor
Serial.print(sensors[0]);
Serial.print(" ");
Serial.print(sensors[1]);
Serial.print(" ");
Serial.print(sensors[2]);
Serial.print(" ");
Serial.print(sensors[3]);
Serial.print(" ");
Serial.print(sensors[4]);
Serial.print(" ");
Serial.println();
}