Thanks a lot,
But it still doesn't work.
/*
Connection details :
1. SOUT pin of RFID1 in to digital pin 8.
2. SOUT pin of RFID2_out to digital pin 2 .
*/
#include <SoftwareSerial.h>
SoftwareSerial nssi1(2, 3);
SoftwareSerial nssi2(8, 9);
//RFID
int val = 0;
char code[] = " ";
int bytesread = 0;
int counter = 0;
char prev_code[] = "- ";
int prev_in = 2;
int p = 0;
void setup()
{
Serial.begin(9600);
nssi1.begin(9600);
nssi2.begin(9600);
Serial.println("Swipe Rfid card");
}
void loop()
{
if (p == 0){ //Each 2 sec scan for each RFIDs
//RFID 1
if(nssi1.available() > 0) { // if data available from reader2
if((val = nssi1.read()) == 10) { // check for heade
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( nssi1.available() > 0) {
val = nssi1.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
}
}
if(bytesread == 10) { // if 10 digit read is complete
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
Serial.println("Data from 1st RFID");
}
}
else
{
//RFID 2
if(nssi2.available() > 0) { // if data available from reader2
if((val = nssi2.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( nssi2.available() > 0) {
val = nssi2.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
}
}
if(bytesread == 10) { // if 10 digit read is complete
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
Serial.println("Data from 2nd RFID");
}
}
p = 1-p;
bytesread = 0;
delay(500);
}
I get correct data from one reader but not the other. And it works very will when I just one reader.