RFID Card Reader issue - Parallax card reader

Hello,

I’m trying to make sense out of the data i’m getting out of this RFID card reader.

https://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/RFID/List/0/SortField/4/ProductID/114/Default.aspx

Manual

https://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/28140-28340-RFIDreader-v2.2.pdf

Forgive my lack of comments in the program, and my lack of eloquence in the following video.

Any help trying to figure out how to get clean data out of the card would be much appreciated.

thank you,

Erti

Code:

/*
RFID
*/
int Power = 11;
int Enable = 12;
int Read = 13;
int Instructions = 0;

void setup() {
pinMode(Power, OUTPUT); // Power
pinMode(Enable, OUTPUT); // Enable
pinMode(Read, INPUT); // Serial Input
digitalWrite(Power, LOW);
digitalWrite(Enable, HIGH);
Serial.begin(2400);
}

void loop() {
Instructions = ‘5’;
if (Serial.available() > 0) Instructions = Serial.read();
if (Instructions == ‘1’) { digitalWrite(Power, HIGH); Serial.println(“Powered ON”); }
if (Instructions == ‘0’){ digitalWrite(Power, LOW); Serial.println(“Powered OFF”);}
if (Instructions == ‘2’){ digitalWrite(Enable, LOW); Serial.println(“Enabled”);
while(Instructions != ‘3’){
for (int i = 0; i < 96; i++) Serial.print(digitalRead(Read), BIN);
Serial.println();
if (Serial.available() > 0) Instructions = Serial.read();
} digitalWrite(Enable, HIGH); Serial.println(“Disabled”);}
}

the code is wrong. use NewSofterSerial to create another serial on some pin but NOT 0 and 1 (this is the harware serial used to communicate with PC).
RX of the new serial has to be linked with card reader's PIN 3
another digital pin has to be linked with card reader's PIN 2

new serial has to have baud-rate of 2400, luckily the other setting are the standard used.
Now put the digital pin to HIGH, and start to read the new serial: here it is!
if you want to stop reading, just put the digital pin to LOW
this is helpful if you don't want to read more than one time the same card: just put LOW the digital pin for 1 or 2 second and you are ok, but IMHO is better if you still read it and simply eliminate consecutive read of the same code in a small amount of time (like a de-bounce code for button!).

ah, link reader's GND to arduino's GND :slight_smile:

// PARALLAX RFID VCC     to Arduino 5V
// PARALLAX RFID /ENABLE to Arduino D2
// PARALLAX RFID SOUT    to Arduino D3
// PARALLAX RFID GND     to Arduino Gnd

// Modified by Worapoht K.
#include <SoftwareSerial.h>

#define enablePin 2
#define rxPin 3
#define txPin 4

SoftwareSerial RFID = SoftwareSerial(rxPin, txPin); 

#define START_CHAR 10
#define END_CHAR 13

void setup()
{ 
  Serial.begin(9600);  // Hardware serial for Monitor 2400bps
  RFID.begin(2400);    // RFID reader SOUT at 2400bps

  pinMode(enablePin,OUTPUT);       // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin 
  digitalWrite(enablePin, LOW);    // Activate the RFID reader 
}


void loop()
{
  int bytesread, val;
  String code = "";

  digitalWrite(enablePin, LOW);    // Activate the RFID reader

  // Wait for header byte
  while(RFID.read() != START_CHAR) 
    /* DO NOTHING */    ;

  bytesread = 0;
  while ((val = RFID.read()) != END_CHAR)
  {
    if (val == START_CHAR)
      break; // Bad frame
    bytesread++;
    if (bytesread > 10)
      break;  // Too many characters
    code += val;     // append the character  
  }

  digitalWrite(enablePin, HIGH);    // Deactivate the RFID reader 

  if (bytesread == 10)  // Valid read.  10 characters + END_CHAR
  {  // if 10 digit read is complete 
    if (code == "48524953696548555648")
      Serial.println("That's the round tag.");
    else
      if (code == "48704851485249505067")
        Serial.println("That's the rectangular tag.");
      else
      {
        Serial.print("Unrecognized code: ");   // possibly a good TAG 
        Serial.println(code);            // print the TAG code 
      }

  }

  delay(1000);                       // wait for a second
}