This RFID reader will read a keycode and print it to a 16×2 lcd and also print it through serial.  You will need:

  • Arduino with USB cable
  • Arduino Sketch
  • 16×2 LCD (optional)
  1. Connect RFID reader from sout to pin 8 and enable to pin 7. Upload the following sketch and off you go.  If you wish not to use an LCD just comment out the lines using “//” that mention “lcd”.

// RFID reader for Arduino
#include <SoftwareSerial.h>

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight
int val = 0;
int x = 0;
char code[10];
int bytesread = 0;
#define rxPin 8
#define txPin 1
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
byte backSlash[8] = {
0, 16, 8, 4, 2, 1, 0, 0};
void setup() {
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH);
RFID.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
pinMode(7,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(7, LOW); // Activate the RFID reader
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear();
}


void loop() {
lcd.createChar(3, backSlash);
if(x == 0) {
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Waiting For RFID");
lcd.setCursor(0,1);
lcd.print("#.#.#. | .#.#.#.");
delay(500);
x++;
}
else if(x == 1) {
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Waiting For RFID");
lcd.setCursor(0,1);
lcd.print(".#.#.# #.#.#.#");
lcd.setCursor(7,1);
lcd.write(3);
delay(500);
x++;
}
else if(x == 2) {
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Waiting For RFID");
lcd.setCursor(0,1);
lcd.print("#.#.#. - .#.#.#.");
delay(500);
x++;
}
else if(x == 3) {
//lcd.clear();
lcd.setCursor(0,0);
lcd.print("Waiting For RFID");
lcd.setCursor(0,1);
lcd.print(".#.#.# / #.#.#.#");
delay(500);
x = 0;
}
if(RFID.available() > 0) { // if data available from reader
if((val = RFID.read()) == 10) { // check for header
bytesread = 0;
while(bytesread 0) {
val = RFID.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
// lcd.setCursor(1,bytesread);
// lcd.print(val);
bytesread++; // ready to read next digit
}
}
if(bytesread == 10) { // if 10 digit read is complete
RFID.print("Keycode is: "); // possibly a good TAG
RFID.println(code); // print the TAG code
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RFID Code is....");
lcd.setCursor(0,1);
lcd.print(code);
lcd.setCursor(10,1);
lcd.print(" ");
RFID.flush();
}
bytesread = 0;
digitalWrite(7, HIGH); // deactivate the RFID reader for a moment so it will not flood
delay(10000);
lcd.clear();
RFID.flush();
digitalWrite(7, LOW); // Activate the RFID reader
}
}
}

Leave a Reply