TSC3200 with Line follower

hi,

I want to use TSC3200 sensor with line follower, while line follower walks, it will detect the color, but it doesnt work properly beacuse of the interrupts of the TSC3200.

How can I achieve that problem?

here is the my code

#include <TimerOne.h>
#include <QTRSensors.h>
#include <Servo.h>
#define NUM_SENSORS       8    // number of sensors used
#define TIMEOUT           2500  // waits for 2900 microseconds for sensor outputs to go low
#define EMITTER_PIN       37     // emitter is controlled by digital pin 2 //emiter iptal edildi
#define SOL_SABIT_HIZ 210
#define SAG_SABIT_HIZ 210   //85
#define M1_MAX_SPEED 210 //100
#define M2_MAX_SPEED 210

#define Motor_Sol_1       24
#define Motor_Sol_2       22 
#define Motor_Sol_PWM     3

#define Motor_Sag_3       28 
#define Motor_Sag_4       26 
#define Motor_Sag_PWM     4

#define DEBUG 1


#define S0     37
#define S1     39
#define S2     41
#define S3     43
#define OUT    21


 const int stepPin = 47; 
const int dirPin = 49; 
Servo servo;  
Servo servo2;  
int angle = 0;   // servo position in degrees 
int angle2 = 0; 

int g_count= 0;
int g_array[3];
int g_flag=0;
float g_SF[3];
int renk[3];
QTRSensorsRC qtrrc((unsigned char[]) {34,36,38,40,42,44,46,48},   
  NUM_SENSORS, TIMEOUT, QTR_EMITTERS_ON); 
unsigned int sensorValues[NUM_SENSORS];

void setup() {
   pinMode(53,OUTPUT);
   
   servo.attach(A4); 
servo2.attach(A0);
pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
  pinMode(45,OUTPUT);
  digitalWrite(45,HIGH);
 TSC_Init();

  Timer1.initialize();             // defaulte is 1s
  Timer1.attachInterrupt(TSC_Callback);
  attachInterrupt(2, TSC_Count, RISING);

  delay(500);

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

  g_SF[0] = 255.0/ g_array[0];     //R Scale factor
  g_SF[1] = 255.0/ g_array[1] ;    //G Scale factor
  g_SF[2] = 255.0/ g_array[2] ;    //B Scale factor
  }
 delay(200);
digitalWrite(31, HIGH);
digitalWrite(33, HIGH);
digitalWrite(29, HIGH);
digitalWrite(27, HIGH);

 Motor();
 manual_calibration();




  
 
}
 
int hiz=190;
int baslangic_hiz=190;
 int kontrol=0;
int git=6;
float bekle=0.5;
int git_m=5;
float bekle_m=0.5;
float onceki_hata=0;
int sayacyesil=0;
int sayacsari=0;
int sayackirmizi=0;
int sayacmavi=0;
int zemin=0; 
void loop() { 
  
  digitalWrite(31, LOW);
digitalWrite(33, LOW);
digitalWrite(29, LOW);
digitalWrite(27, LOW);
  int sol3_Min, sol2_Min, sol1_Min, sol_Min, sag_Min, sag1_Min, sag2_Min, sag3_Min;
  int sol3, sol2, sol1, sol, sag, sag1, sag2, sag3, sol_Analog, orta_Analog, sag_Analog, miklatis;
  int sol_MotorHiz = 0;
  int sag_MotorHiz =0;
  float Kp = 3;
  float Kd =30; // 30
  float hataOrani=0;
   
  float turev=0;
  float P=0;
  float D=0;
  float PID =0;  
  miklatis=0;
  sol_Analog=0;
  orta_Analog=0;
  sag_Analog=0;
  sol3=0;
  sol2=0;
  sol1=0;
  sol=0;
  sag=0;
  sag1=0;
  sag2=0;
  sag3=0;
  

  int position = qtrrc.readLine(sensorValues);
  sol3=sensorValues[0];
  sol2=sensorValues[1];
  sol1=sensorValues[2];
  sol=sensorValues[3];
  sag=sensorValues[4];
  sag1=sensorValues[5];
  sag2=sensorValues[6];
  sag3=sensorValues[7];
  sol3_Min=qtrrc.calibratedMinimumOn[0];
  sol2_Min=qtrrc.calibratedMinimumOn[1];
  sol1_Min=qtrrc.calibratedMinimumOn[2];
  sol_Min=qtrrc.calibratedMinimumOn[3];
  sag_Min=qtrrc.calibratedMinimumOn[4];
  sag1_Min=qtrrc.calibratedMinimumOn[5];
  sag2_Min=qtrrc.calibratedMinimumOn[6];
  sag3_Min=qtrrc.calibratedMinimumOn[7];
  
  
  /*if(sol3>sol3_Min && sag3>sag3_Min && sol_Analog >730 && sag_Analog >730 && zemin==1) 
  {
      dur(); 
      delay(150);
      zemin=0;
  }  
  
   if(zemin==0)
  {
      hataOrani = position-3500;
  } 
   
  if(sol3<=sol3_Min && sag3<=sag3_Min && sol_Analog <=730 && sag_Analog <=730 && zemin==0) 
  {
    zemin=1;
      dur(); 
      delay(150);
  }*/
  zemin=1;
 
      hataOrani = position-3500;



  turev = hataOrani-onceki_hata;
  P = Kp * hataOrani;
  D = Kd * turev;
  PID = (P  + D); 
  sol_MotorHiz = SOL_SABIT_HIZ + PID;
  sag_MotorHiz = SAG_SABIT_HIZ - PID;
  onceki_hata = hataOrani;  
  ileri(sag_MotorHiz,sol_MotorHiz);
  delay(1);
   g_flag = 0;
      
      
  for(int i=0; i<3; i++)
   {
    renk[i]=(g_array[i] * g_SF[i]);
    }
    //color(); 
    if(renk[0]-renk[1]<=20 && renk[0]-renk[1]<=20 && renk[1]-renk[0]<=20 && renk[1]-renk[2]<=20 && renk[2]-renk[1]<=20 && renk[2]-renk[0]<=20 && renk[0]<=55 && renk[1]<=55 && renk[2]<=55)
{ digitalWrite(31, LOW);
digitalWrite(33, LOW);
digitalWrite(29, LOW);
digitalWrite(27, LOW);
sayacyesil=0;
sayacmavi=0;
sayacsari=0;
sayackirmizi=0;
}//beyaz

else if(renk[0]-renk[1]<=20 && renk[0]-renk[1]<=20 && renk[1]-renk[0]<=20 && renk[1]-renk[2]<=20 && renk[2]-renk[1]<=20 && renk[2]-renk[0]<=20 && renk[0]>=60 && renk[1]>=60 && renk[2]>=60)
{ digitalWrite(31, HIGH);
digitalWrite(33, HIGH);
digitalWrite(29, HIGH);
digitalWrite(27, HIGH);

sayacyesil=0;
sayacmavi=0;
sayacsari=0;
sayackirmizi=0;
}//siyah
else if(renk[0]>renk[1]&&renk[0]>renk[2] && ((renk[1]-renk[2])<15 && renk[0]-renk[1]>=30)){ 
  digitalWrite(33, HIGH);
digitalWrite(31, LOW);
digitalWrite(29, LOW);
digitalWrite(27, LOW);
sayacyesil=0;
sayacmavi=0;
sayacsari=0;
sayackirmizi++;



}//kırmızı
  else if(renk[1]>renk[0]&&renk[1]>renk[2] && renk[0]>renk[2]){ digitalWrite(29, HIGH);
digitalWrite(33, LOW);
digitalWrite(31, LOW);
digitalWrite(27, LOW);
sayacyesil++;
sayacmavi=0;
sayacsari=0;
sayackirmizi=0;
}//yeşil
 else if(renk[2]>renk[1]&&renk[2]>renk[0]&& renk[1]>renk[0] ){ digitalWrite(27, HIGH);
digitalWrite(31, LOW);
digitalWrite(29, LOW);
digitalWrite(33, LOW);
sayacyesil=0;
sayacmavi++;
sayacsari=0;
sayackirmizi=0;
}//mavi
  else if(renk[0]>renk[1]&&renk[0]>renk[2] && ((renk[0]-renk[1])<30)&& renk[1]-renk[2]>=20){ digitalWrite(31, HIGH);
digitalWrite(33, LOW);
digitalWrite(29, LOW);
digitalWrite(27, LOW);
sayacyesil=0;
sayacmavi=0;
sayacsari++;
sayackirmizi=0;

}//sari
   
    /*if(sayacyesil>=20){dur();geri(200,200);delay(150);dur();al();geri(100,100);delay(1000);sayacyesil=0;}
     if(sayacmavi>=20){dur();geri(200,200);delay(150);dur();al();delay(300);
   
     geri(150,150);
     delay(3000);
   
     
   
 
 dur();delay(1000);sola( sol3, sag3); sayacmavi=0;}
      if(sayackirmizi>=20){dur();geri(200,200);delay(150);dur();al();geri(100,100);delay(1000);sayackirmizi=0;}
       if(sayacsari>=20){dur();geri(200,200);delay(150);dur();al();geri(100,100);delay(1000);sayacsari=0;}


 /*
 
   
   if((sol3 <= sol3_Min || sol2 <= sol2_Min ) && (sol <= sol_Min  || sag <= sag_Min) && (sag2 <= sag2_Min || sag3 <= sag3_Min))     //  sensorler beyazda sola don
    {
      
     
          
         sola( sol3, sag3); 
      
    } 
    
    if((sol3 <= sol3_Min) && (sol <= sol_Min  || sag <= sag_Min) && (sag2 > sag2_Min || sag3 > sag3_Min))     //  beyaz beyaz siyah sensor sola don
    {
      
    
  //   sola( sol3, sag3);    
    } 
    
    /*if((sol3 > sol3_Min && sol2 > sol2_Min && sol1 > sol1_Min) && (sol <= sol_Min  || sag <= sag_Min) && (sag1 <= sag1_Min && sag2 <= sag2_Min && sag3 <= sag3_Min))     //  siyah beyaz beyaz 
    {
       
       
         saga(sol3, sol2, sol1, sol, sag, sag1, sag2, sag3, sol_Analog, orta_Analog, sag_Analog,sol3_Min);      
      }
       else 
       {
           //diziye ileri at
          digitalWrite(6, HIGH); delay(13); digitalWrite(6, LOW);
          ileri(sag_MotorHiz,sol_MotorHiz);
          delay(2);     
       }*/
 //   
  
}


void color()  
{    
  digitalWrite(S2, LOW);  
  digitalWrite(S3, LOW);  
  //count OUT, pRed, RED  
  renk[0] = pulseIn(OUT, digitalRead(OUT) == HIGH ? LOW : HIGH);  
  digitalWrite(S3, HIGH);  
  //count OUT, pBLUE, BLUE  
  renk[2] = pulseIn(OUT, digitalRead(OUT) == HIGH ? LOW : HIGH);  
  digitalWrite(S2, HIGH);  
  //count OUT, pGreen, GREEN  
  renk[1]= pulseIn(OUT, digitalRead(OUT) == HIGH ? LOW : HIGH);  
}
void al(){


servo.write(90); 
      servo2.write(90); 
       for(angle = 90; angle >=20; angle--)  
  {                                  
          servo.write(angle);  
   
    delay(15);                   
  } 
  delay(500);
 for(angle2 = 90; angle2 >=15; angle2--)  
  {                                  
          servo2.write(angle2);  
   
    delay(15);                   
  } 
  delay(500);
  
   for(angle = 20; angle <180; angle++)  
  {                                  
          servo.write(angle);  
   
    delay(15);                   
  } 
    delay(500);
  
   for(angle2 = 15; angle2 <180; angle2++)  
  {                                  
          servo2.write(angle2);  
   
    delay(15);                   
  } 
     delay(500);
  
   for(angle = 180; angle >=100; angle--)  
  {                                  
          servo.write(angle);  
   
    delay(5);                   
  } 
   delay(500);
   for(angle = 100; angle <180; angle++)  
  {                                  
          servo.write(angle);  
   
    delay(5);                   
  } 
    delay(500);
   for(angle = 180; angle >=100; angle--)  
  {                                  
          servo.write(angle);  
   
    delay(5);                   
  } 
    delay(500);
  
   for(angle2 = 180; angle2 >100; angle2--)  
  {                                  
          servo2.write(angle2);  
   
    delay(15);                   
  } 
  delay(750);
   digitalWrite(45,LOW); 
  digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation

    if(kontrol==2 ){
          for(int x = 0; x < 33; x++) {
              digitalWrite(stepPin,HIGH); 
              delay(20); 
              digitalWrite(stepPin,LOW); 
              delay(20); 
            }
            }
            else if(kontrol==5){
            for(int x = 0; x < 35; x++) {
              digitalWrite(stepPin,HIGH); 
              delay(20); 
              digitalWrite(stepPin,LOW); 
              delay(20); 
            }
            }
            else{
              for(int x = 0; x < 33; x++) {
              digitalWrite(stepPin,HIGH); 
              delay(20); 
              digitalWrite(stepPin,LOW); 
              delay(20); 
            }
            }

}
void saga_miklatis(int sol3, int sol2, int sol1, int sol, int sag, int sag1, int sag2, int sag3, int sol_Analog, int orta_Analog, int sag_Analog){
  int degisken=0; 
  int sol3_Min, sol2_Min, sol1_Min, sol_Min, sag_Min, sag1_Min, sag2_Min, sag3_Min;  
  while(1)
  {     
      hiz++;
      sol_Analog=analogRead(A1);
      orta_Analog=analogRead(A2);
      sag_Analog=analogRead(A3);
      int position = qtrrc.readLine(sensorValues);
      sol3=sensorValues[0];
      sol2=sensorValues[1];
      sol1=sensorValues[2];
      sol=sensorValues[3];
      sag=sensorValues[4];
      sag1=sensorValues[5];
      sag2=sensorValues[6];
      sag3=sensorValues[7]; 
      sol3_Min=qtrrc.calibratedMinimumOn[0];
      sol2_Min=qtrrc.calibratedMinimumOn[1];
      sol1_Min=qtrrc.calibratedMinimumOn[2];
      sol_Min=qtrrc.calibratedMinimumOn[3];
      sag_Min=qtrrc.calibratedMinimumOn[4];
      sag1_Min=qtrrc.calibratedMinimumOn[5];
      sag2_Min=qtrrc.calibratedMinimumOn[6];
      sag3_Min=qtrrc.calibratedMinimumOn[7];   
      
      if(sol3 <= sol3_Min)
      {      
        degisken=1;
      }
      if(degisken==1 && sag3 <= sag3_Min)
      {
        degisken=2;
      }
      if(degisken==2 && sag3 > sag3_Min && sol3 > sag3_Min)
      {
        degisken=0;
        hiz=baslangic_hiz;
        break;        
      }

        if(hiz  >=  90){hiz=80;} 
        digitalWrite(Motor_Sag_3, LOW);
        digitalWrite(Motor_Sag_4, HIGH); 
        digitalWrite(Motor_Sol_1, HIGH);
        digitalWrite(Motor_Sol_2, LOW);
        analogWrite(Motor_Sag_PWM, hiz+35);
        analogWrite(Motor_Sol_PWM, hiz+35); 
        delay(git_m);
        dur();
        delay(bekle_m);
        
  }
}
void saga(int sol3, int sol2, int sol1, int sol, int sag, int sag1, int sag2, int sag3, int sol_Analog, int orta_Analog, int sag_Analog, int sol3_Min)
{
  int degisken=0;
  while(1)
  {   
      hiz++;
      sol_Analog=analogRead(A1);
      orta_Analog=analogRead(A2);
      sag_Analog=analogRead(A3);
      int position = qtrrc.readLine(sensorValues);
      sol3=sensorValues[0];
      sol2=sensorValues[1];
      sol1=sensorValues[2];
      sol=sensorValues[3];
      sag=sensorValues[4];
      sag1=sensorValues[5];
      sag2=sensorValues[6];
      sag3=sensorValues[7];
      
      if(sag_Analog <= 720)
      {      
        degisken=1;
      }
       else if(degisken==1)
        {
          if(sag_Analog > 720)
          {
            degisken=2;
          }
        }
        else if((degisken==2) )
        {
          if((orta_Analog <= 720))
          {
            degisken=0;
            delay(100);
            hiz=baslangic_hiz;
            break;
          }
        }
     
        if(hiz  >=  90){hiz=80;} 
        digitalWrite(Motor_Sag_3, LOW);
        digitalWrite(Motor_Sag_4, HIGH); 
        digitalWrite(Motor_Sol_1, HIGH);
        digitalWrite(Motor_Sol_2, LOW);
        analogWrite(Motor_Sag_PWM, hiz+20);
        analogWrite(Motor_Sol_PWM, hiz+20); 
        delay(git);
        dur();
        delay(bekle);
        
  }

}

/*void sola(int sol3, int sol2, int sol1, int sol, int sag, int sag1, int sag2, int sag3, int sol_Analog, int orta_Analog, int sag_Analog,int sol3_Min)
{
  int degisken=0;
   int kontrol=0;
  while(1)
  {
      hiz++;
      sol_Analog=analogRead(A1);
      orta_Analog=analogRead(A2);
      sag_Analog=analogRead(A3);
      int position = qtrrc.readLine(sensorValues);
      sol3=sensorValues[0];
      sol2=sensorValues[1];
      sol1=sensorValues[2];
      sol=sensorValues[3];
      sag=sensorValues[4];
      sag1=sensorValues[5];
      sag2=sensorValues[6];
      sag3=sensorValues[7];      
      hiz++;
      
      if(sol_Analog <= 720)
      {      
        degisken=1;
      }
       else if(degisken==1)
        {
          if(sol_Analog > 720)
          {
            degisken=2;  
          }
        }
        else if((degisken==2) )
        {
          if((orta_Analog <= 720))
          {
            degisken=0;
            delay(100);
            hiz=baslangic_hiz;
            break;
          }
        }

        if(sol3 > sol3_Min) kontrol=1;
        else if(kontrol==1 && (sol3 <= sol3_Min)) kontrol=2;
        else if(kontrol==2 && (sol3 > sol3_Min)) {kontrol=0; break;}
        
        if(hiz  >=  90){hiz=75;} 
        digitalWrite(Motor_Sag_3, HIGH);
        digitalWrite(Motor_Sag_4, LOW); 
        digitalWrite(Motor_Sol_1, LOW);
        digitalWrite(Motor_Sol_2, HIGH);
        analogWrite(Motor_Sag_PWM, hiz+20);
        analogWrite(Motor_Sol_PWM, hiz+20); 
        delay(git);
        dur();
        delay(bekle);
        
  }

}*/
void sola(int min0, int min5){
          digitalWrite(Motor_Sag_3, LOW);
        digitalWrite(Motor_Sag_4, HIGH); 
        digitalWrite(Motor_Sol_1, LOW);
        digitalWrite(Motor_Sol_2, HIGH);
        analogWrite(Motor_Sag_PWM, hiz+60);
        analogWrite(Motor_Sol_PWM, hiz+25); 
       
          while(kontrol<2)
          {
            int position = qtrrc.readLine(sensorValues);
            if(sensorValues[5] > min5 && sensorValues[2] > min5 && sensorValues[3] > min5 )
            {
               int position = qtrrc.readLine(sensorValues);
               if(sensorValues[2] <= min5+50 || sensorValues[3] <= min5+50 ) {kontrol=10;}              
                 digitalWrite(Motor_Sag_3, LOW);
        digitalWrite(Motor_Sag_4, HIGH); 
        digitalWrite(Motor_Sol_1, LOW);
        digitalWrite(Motor_Sol_2, HIGH);
        analogWrite(Motor_Sag_PWM, hiz+60);
        analogWrite(Motor_Sol_PWM, hiz+25); 
                    
             }
            else if (sensorValues[5] > min5)
             {
               int position = qtrrc.readLine(sensorValues);
               if(sensorValues[2] <= min5+50 || sensorValues[3] <= min5+50 ) {kontrol=10;}
             }
          }
         kontrol=0;
}
void geri(int motor1speed, int motor2speed)
{
  if (motor1speed > M1_MAX_SPEED ) motor1speed = M1_MAX_SPEED; // limit top speed
  if (motor2speed > M2_MAX_SPEED ) motor2speed = M2_MAX_SPEED; // limit top speed
  if (motor1speed < 0) motor1speed = 0; // keep motor above 0
  if (motor2speed < 0) motor2speed = 0; // keep motor speed above 0
    
 digitalWrite(Motor_Sol_1, LOW);
  digitalWrite(Motor_Sol_2, HIGH); 
  digitalWrite(Motor_Sag_3, HIGH);
  digitalWrite(Motor_Sag_4, LOW);
  analogWrite(Motor_Sag_PWM, motor1speed);
  analogWrite(Motor_Sol_PWM, motor2speed);  
}
void ileri(int motor1speed, int motor2speed)
{
  if (motor1speed > M1_MAX_SPEED ) motor1speed = M1_MAX_SPEED; // limit top speed
  if (motor2speed > M2_MAX_SPEED ) motor2speed = M2_MAX_SPEED; // limit top speed
  if (motor1speed < 0) motor1speed = 0; // keep motor above 0
  if (motor2speed < 0) motor2speed = 0; // keep motor speed above 0
    
 digitalWrite(Motor_Sol_1, HIGH);
  digitalWrite(Motor_Sol_2, LOW); 
  digitalWrite(Motor_Sag_3, LOW);
  digitalWrite(Motor_Sag_4, HIGH);
  analogWrite(Motor_Sag_PWM, motor1speed);
  analogWrite(Motor_Sol_PWM, motor2speed);  
}
void manual_calibration() {
  
  int i;
  for (i = 0; i <= 150; i++)  //250
  {
    qtrrc.calibrate(QTR_EMITTERS_ON);
    delay(20);
  }
  
  if (DEBUG) { // if true, generate sensor dats via serial output
    Serial.begin(9600);
    for (int i = 0; i < NUM_SENSORS; i++)
    {
      Serial.print(qtrrc.calibratedMinimumOn[i]);
      Serial.print(' ');
    }
    Serial.println();

    for (int i = 0; i < NUM_SENSORS; i++)
    {
      Serial.print(qtrrc.calibratedMaximumOn[i]);
      Serial.print(' ');
    }
    Serial.println();
    Serial.println();  
  }
}
void Motor(){
  pinMode(Motor_Sol_1, OUTPUT);
  pinMode(Motor_Sol_2, OUTPUT);
  pinMode(Motor_Sag_PWM, OUTPUT);
  pinMode(Motor_Sag_3, OUTPUT);
  pinMode(Motor_Sag_4, OUTPUT);
  pinMode(Motor_Sol_PWM, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
      digitalWrite(50, HIGH);
}
void dur(){
  analogWrite(Motor_Sag_PWM, 255);
  analogWrite(Motor_Sol_PWM, 255);   
  digitalWrite(Motor_Sol_1, HIGH);
  digitalWrite(Motor_Sol_2, HIGH);
  digitalWrite(Motor_Sag_3, HIGH);
  digitalWrite(Motor_Sag_4, HIGH);
  delay(3000);
}

// Init TSC230 and setting Frequency.
void TSC_Init()
{
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(OUT, INPUT);
    pinMode(33, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(27, OUTPUT);
digitalWrite(33, LOW);
digitalWrite(29, LOW);
digitalWrite(27, LOW);
digitalWrite(31, LOW);
  digitalWrite(S0, HIGH);  // OUTPUT FREQUENCY SCALING 2%
  digitalWrite(S1, HIGH);
}

// Select the filter color
void TSC_FilterColor(int Level01, int Level02)
{
  if(Level01 != 0)
    Level01 = HIGH;

  if(Level02 != 0)
    Level02 = HIGH;

  digitalWrite(S2, Level01);
  digitalWrite(S3, Level02);
}

void TSC_Count()
{
  g_count ++ ;
}

void TSC_Callback()
{
  switch(g_flag)
  {
    case 0:
        
         TSC_WB(LOW, LOW);              //Filter without Red
         break;
    case 1:
       
         g_array[0] = g_count;
         TSC_WB(HIGH, HIGH);            //Filter without Green
         break;
    case 2:
        
         g_array[1] = g_count;
         TSC_WB(LOW, HIGH);             //Filter without Blue
         break;

    case 3:
         
         g_array[2] = g_count;
         TSC_WB(HIGH, LOW);             //Clear(no filter)
         break;
   default:
         g_count = 0;
         break;
  }
}

void TSC_WB(int Level0, int Level1)      //White Balance
{
  g_count = 0;
  g_flag ++;
  TSC_FilterColor(Level0, Level1);
  Timer1.setPeriod(250);             // set 1s period
}

Hello.

I am sorry you are having trouble getting your line follower to work. Which Pololu sensor(s) are you using? Can you describe exactly what is not working with that sensor? (What behavior do you expect, and what is your robot actually doing?)

By the way, it looks like you posted the entire code for your robot. In the future, it will be easier for anyone to start helping you with your issue if you narrow down the amount of useful information available for them to look at. It would help if you post the simplest version of your code that you think should work, but does not.

-Jon

Thank you Jonathan,

In the loop section according to PID algoritm, the robot follows the line.

Line follower works but I want TSC3200 to detect colors while line follower is following the line.
When I integrated codes both TSC3200 and Qtr8rc, because of the interrupts of the TSC3200, line follower doesnt follow the line properly, it floats too much.

Is there a way to detect color without interrupts while line follower is following the line?

Could anyone give me some idea to achieve that?

We do not carry the TSC3200, so we are not very familiar with it or any libraries made for it. Accordingly, we cannot support it very well. I recommend contacting the person who wrote the library you are using, or writing your own TSC3200 code that doesn’t use interrupts.

-Jon