Problem with TWO sensor arrays

I installed two sensor arrays in my Arduino robot, one QTR-8A and QTR-8RC for line alignment purpose. However, after I initiated both of them separately in two classes, only one of the arrays can read correctly at the same time. And the correct sensor array would shift from one to another randomly with external stimuli(like removing a wire and reconnect it). I doubt it’s something in the library which prevents me from reading both of them. I’ve attached my code below for your reference. Any suggestions?

[code]#include “QTRSensors.h”

#define NUM_SENSORS 8 // number of sensors used
#define NUM_SAMPLES_PER_SENSOR 4 // average 4 analog samples per sensor reading
#define EMITTER_PIN_A 52 // emitter is controlled by digital pin 2
#define EMITTER_PIN_D 37
#define TIMEOUT 2500
// sensors 0 through 5 are connected to analog inputs 0 through 5, respectively
QTRSensorsAnalog qtra((unsigned char[]) {8, 9, 10, 11, 12, 13, 14, 15},
NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN_A);
unsigned int sensorValues_A[NUM_SENSORS];
QTRSensorsRC qtrrc((unsigned char[]) {39, 41, 43, 45, 47, 49, 51, 53},
NUM_SENSORS, TIMEOUT, EMITTER_PIN_D);
unsigned int sensorValues_D[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 < 200; 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)
qtrrc.calibrate();
}
digitalWrite(13, LOW);

Serial.begin(9600);
for (int i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtra.calibratedMinimumOn[i]);
Serial.print(’ ');
}
Serial.println();

for (int i = 0; i < NUM_SENSORS; i++)
{
Serial.print(qtra.calibratedMaximumOn[i]);
Serial.print(’ ');
}
Serial.println();
Serial.println();
delay(1000);
}

void loop()
{

unsigned int position_F = qtra.readLine(sensorValues_A);
unsigned int position_R = qtrrc.readLine(sensorValues_D);

for (unsigned char i = 0; i < NUM_SENSORS; i++)
{
Serial.print(sensorValues_A[i]);
Serial.print(’\t’);
}
Serial.println();
Serial.println(position_F);
for (unsigned char i = 0; i < NUM_SENSORS; i++)
{
Serial.print(sensorValues_D[i]);
Serial.print(’\t’);
}
Serial.println(position_R);
Serial.println(“END”);
delay(250);
}[/code]

Hello.

Using our QTR sensor library, you should be able to control multiple arrays as separate QTRSensors objects. I briefly looked through your code and did not notice anything obviously wrong that might be causing the problem. Could you post some pictures of your setup that show all of your connections? You might try testing the QTR-8A and QTR-8RC sensor arrays one at a time to make sure they are individually working as expected.

-Brandon