PID Line follower(QTR-8RC - L293D Motor Shield)

I am making a line following robot using PID. I have QTR-8RC sensor. I just order it online and received yesterday. When I attached QTR with my robot, It was not emitting LED, not even power on LED. I want to confirm that is there any other method to turn on these LED’s or there is a hardware damage with them.
Robot is emitting violet light(IR perhaps). I was able to see them when I turned on my mobile camera. I placed my code below. My robot is not working well. it’s working for a while and suddenly starting moving circular. I have a doubt that it is not calibrating sensors well. Can any one help me to solve this problem.

// Code...............
#include<QTRSensors.h>

#define Kp 0.1 // experiment to determine this, start by something small that just makes your bot follow the line at a slow speed
#define Kd 5 // experiment to determine this, slowly increase the speeds and adjust this value. ( Note: Kp < Kd) 
#define ki 0   // This can be used if needed.
#define TIMEOUT       1000  // waits for 2500 us for sensor outputs to go low
int num_sensors = 8;

int rightBaseSpeed = 200;
int leftBaseSpeed = 200;

int rightMaxSpeed = 254;
int leftMaxSpeed = 254;

//*****************************************
#include<AFMotor.h>

AF_DCMotor leftMotor(3); // left motor M1a
AF_DCMotor rightMotor(2); // Right motor M2a


int integral = 0;
int derivative = 0;

QTRSensorsRC qtrrc((unsigned char[]) {2,13,14,15,16,17,18,19 }, num_sensors , 2500, QTR_NO_EMITTER_PIN);

void setup()
{

Serial.begin(9600);

for(int i = 0 ;  i < 33 ;  i++)
{

if(i  < 9 || i >= 25)
  turnRight();
else
  turnLeft();
  
  qtrrc.calibrate();
  delay(10); //20
}

wait();
delay(TIMEOUT);
} 

int lastError = 0;

void loop()
{
  unsigned int sensors[8]; 
  int position = qtrrc.readLine(sensors); // get calibrated readings along with the line position, refer to the QTR Sensors Arduino Library for more details on line position.
  int error = position - 3500 ;

//Serial.println(position);

  integral  =  integral + error;

  derivative = error - lastError;

  int motorSpeed = Kp * error + Kd * derivative + ki * integral ;
  lastError = error;

  int rightMotorSpeed = rightBaseSpeed + motorSpeed;
  int leftMotorSpeed = leftBaseSpeed - motorSpeed;
  
  if (rightMotorSpeed > rightMaxSpeed ) rightMotorSpeed = rightMaxSpeed; // prevent the motor from going beyond max speed
  if (leftMotorSpeed > leftMaxSpeed ) leftMotorSpeed = leftMaxSpeed; // prevent the motor from going beyond max speed
  
  if (rightMotorSpeed < 0) rightMotorSpeed = 0; // keep the motor speed positive
  if (leftMotorSpeed < 0) leftMotorSpeed = 0; // keep the motor speed positive
  
   {
    
 leftMotor.run(FORWARD);
 rightMotor.run(FORWARD);
 leftMotor.setSpeed(rightMotorSpeed);
 rightMotor.setSpeed(leftMotorSpeed);  

}
}

void turnLeft(){
 leftMotor.run(BACKWARD);
 rightMotor.run(FORWARD);
 leftMotor.setSpeed(180); //180
 rightMotor.setSpeed(180);  //180  
  }
  
void turnRight(){
 leftMotor.run(FORWARD);
 rightMotor.run(BACKWARD);
 leftMotor.setSpeed(180); //180
 rightMotor.setSpeed(180);  //180  
  }


  
void wait(){
 leftMotor.run(RELEASE);
 rightMotor.run(RELEASE);

}

Hello.

The LEDs on the QTR-8RC Reflectance Sensor Array emit IR light. This is mentioned on its product page and in its user’s guide, which is linked under the “Resources” tab on the product page. The state of the IR LEDs on the sensor array can be controlled with the LEDON pin. When left disconnected, the pin is internally pulled high and all the LEDs are on.

During the calibration phase, is your robot rotating far enough to the left and right so that all the sensors pass over the lightest and darkest parts of your course? It might be helpful for you to look at the calibration code in the LineFollower example for our Zumo robot, which uses the same sensor modules and principle of operation as the QTR-8RC.

By the way, we deleted your other thread, which seem to be about the same issue but did not contain any details.

- Amanda