Magnetic Stripe Issue

Good day to everybody I need help with code to read track 1 and track 2 at the same with with Arduino Mega, The card reader is a TTL Panasonic with 7 Pins 5v rd1 rdcl1 rd2 rdcl2 crld grnd I have codes that work with t1 and t2 seperate

Also I have code that is supposed to read both tracks at same time but only get couple of numbers when card is swiped

Code that is supposed to work with t1 and t2

#define DATA_T1  12 
#define STROBE_T1 8

#define DATA_T2 11
#define STROBE_T2 9

#define CARDPRESENT 10
#define SERIALRATE 9600

boolean dataStr_T2[600];
boolean dataStr_T1[600];


boolean check_T2;
boolean check_T1;


int dataNum_T2;
int dataNum_T1;

int i;


void setup() {

 Serial.begin(SERIALRATE);
 Serial.println("Begin");

 pinMode(DATA_T2, INPUT);
 pinMode(DATA_T1, INPUT);

 pinMode(STROBE_T2, INPUT);
 pinMode(STROBE_T1, INPUT);

 pinMode(CARDPRESENT, INPUT);

}

void loop() {
  
 resetValues();

 waitForCard();
 Serial.println("Read");
 readData();

 Serial.print("T2:");  
 Serial.println(dataNum_T2);

 Serial.print("T1:");
 Serial.println(dataNum_T1);

 Serial.println("");
}

//*******************************************************

void resetValues() {
  
 dataNum_T2 = 0;
 dataNum_T1 = 0;

 check_T1 = 0;
 check_T2 = 0;
}

//*******************************************************

void waitForCard() {
  
 while (true) 
 {
   if (digitalRead(CARDPRESENT) == LOW) 
   {
     break;
   }
 }
}

//*******************************************************

void readData() {
  
  Serial.println("Read Routine");

  while (true) 
  {
     if (digitalRead(STROBE_T1) == LOW && check_T1 == 1) 
     {
         if (digitalRead(DATA_T1) == HIGH) {
             dataStr_T1[dataNum_T1] = '0';
         }
         else 
         {
             dataStr_T1[dataNum_T1] = '1';
         }
         check_T1 = 0;
         dataNum_T1++;
     }
     else if (check_T1 == 0 && digitalRead(STROBE_T1) == HIGH) 
     {
         check_T1 = 1;
     }
  
     if (digitalRead(STROBE_T2) == LOW && check_T2 == 1) 
     {
         if (digitalRead(DATA_T2) == HIGH)
         {
             dataStr_T2[dataNum_T2] = '0';
         }
         else 
         {
             dataStr_T2[dataNum_T2] = '1';
         }
         check_T2 = 0;
         dataNum_T2++;
     }
     else if (check_T2 == 0 && digitalRead(STROBE_T2) == HIGH) 
     {
         check_T2 = 1;
     }
  
     if (digitalRead(CARDPRESENT) == HIGH) 
     {
      break;
     }
  } 

}

but only get couple of numbers when card is swiped

You only print two numbers, the bit counts. What are the values you see?

You could check your indentation using the ctrl-T tool, and see if your code is structured like you think it should be. It looks to me like reading the T2 strobe is conditional upon the T1 strobe being LOW - is that part of the protocol?

Can you edit your post and put in the code tags, please?

Thanks for the reply Im so sorry but I dont know how to do tags this is my first I will find out how to post like that now and will post again

#define DATA_T1  12 
#define STROBE_T1 8

#define DATA_T2 11
#define STROBE_T2 9

#define CARDPRESENT 10
#define SERIALRATE 9600

boolean dataStr_T2[600];
boolean dataStr_T1[600];


boolean check_T2;
boolean check_T1;


int dataNum_T2;
int dataNum_T1;
int i;


void setup() {

 Serial.begin(SERIALRATE);
 Serial.println("Begin");
 
 pinMode(DATA_T2, INPUT);
 pinMode(DATA_T1, INPUT);
 
 pinMode(STROBE_T2, INPUT);
 pinMode(STROBE_T1, INPUT);
 
 pinMode(CARDPRESENT, INPUT);

}

void loop() {
resetValues();
 
 waitForCard();
 Serial.println("Read");
 readData();

 Serial.print("T2:");  
 Serial.println(dataNum_T2);

 Serial.print("T1:");
 Serial.println(dataNum_T1);

 Serial.println("");
}

//*******************************************************
void resetValues() {
  
 dataNum_T2 = 0;
 dataNum_T1 = 0;
 
 check_T1 = 0;
 check_T2 = 0;
}

//*******************************************************

void waitForCard() {
  
 while (true) 
 {
   if (digitalRead(CARDPRESENT) == LOW) 
   {
     break;
   }
 }
}

//*******************************************************

void readData() {
  
  Serial.println("Read Routine");
 
  while (true) 
  {
     if (digitalRead(STROBE_T1) == LOW && check_T1 == 1) 
     {
         if (digitalRead(DATA_T1) == HIGH) {
             dataStr_T1[dataNum_T1] = '0';
         }
         else 
         {
             dataStr_T1[dataNum_T1] = '1';
         }
         check_T1 = 0;
         dataNum_T1++;
     }
     else if (check_T1 == 0 && digitalRead(STROBE_T1) == HIGH) 
     {
         check_T1 = 1;
     }
  
     if (digitalRead(STROBE_T2) == LOW && check_T2 == 1) 
     {
         if (digitalRead(DATA_T2) == HIGH)
         {
             dataStr_T2[dataNum_T2] = '0';
         }
         else 
         {
             dataStr_T2[dataNum_T2] = '1';
         }
         check_T2 = 0;
         dataNum_T2++;
     }
     else if (check_T2 == 0 && digitalRead(STROBE_T2) == HIGH) 
     {
         check_T2 = 1;
     }
  
     if (digitalRead(CARDPRESENT) == HIGH) 
     {
      break;
     }
  } 

}