I used the code that was from the arduino playground:
int val = 0;
char code[10];
int bytesread = 0;
void setup() {
Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
pinMode(2,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(2, LOW); // Activate the RFID reader
}
void loop() {
if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( Serial.available() > 0) {
val = Serial.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
}
bytesread = 0;
digitalWrite(2, HIGH); // deactivate the RFID reader for a moment so it will not flood
delay(1500); // wait for a bit
digitalWrite(2, LOW); // Activate the RFID reader
}
}
}
When I open the serial monitor and scan the tags, only jibberish words come out. "TAG code is" does not even come out.
I think something is wrong with the bps...I have tried the softwareSerial and it worked when i set the serial.begin(9600) and SoftwareSerial RFID = SoftwareSerial(rxPin,txPin); RFID.begin(2400);
Yeah I am using the aruino fio which needs a FTDI cable that is connected to the RXI. Because the RFiD reader also needs to be connnected to the RX for the SOUT pin, I have both rfid reader and the arduino connected to the serial port. Should I use the softwareserial?
Do you know if there is any site that provides the Newsoftwareserial code for the parallax rfid reader? I know where to download the library but I don't know the code for the rfid reader...
the Newsoftwareserial code for the parallax rfid reader?
No you misunderstand, Newsoftwareserial is code to allow you to read from a pretend serial port, you just substitute calls to that in your RFID code for the calls to the real serial port.