Sunteți pe pagina 1din 4

Search the Arduino Playground

Home

Buy

Download

Products

L earning

Forum

Support

Blog

L OG IN

SIGN UP

Manuals and Curriculum


Arduino StackExchange
Board Setup and Configuration
Development Tools
Arduino on other Atmel Chips
Interfacing With Hardware
- Output
- Input
- User Interface
- Storage
- Communication
- Power supplies
- General

Code for using the Arduino with


the Parallax RFID reader
- NOTE: This page is for use ONLY with the blue, read-only Parallax RFID reader (model # 28140).
For help with the new, black, read/write module (model # 28440), please visit its page

This code lets the Arduino read the Parallax brand RFID reader. Once connected and
programmed, prints the tag number in the serial monitor window. Note that the serial
monitor window runs at an astonishing 2400 baud, so make sure you have your seat belt
buckled!

Interfacing with Software


User Code Library
- Snippets and Sketches

Four easy hardware connections:

- Libraries
- Tutorials

- Arduino RX to RFID TX

Suggestions & Bugs

- Arduino GND to RFID GND

Electronics Technique

- Arduino Digital pin 2 to RFID enable

Sources for Electronic Parts


Related Hardware and

open in browser PRO version

- Arduino +5V to RFID Vcc pin.


// RFID reader for Arduino
Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Initiatives
Arduino People/Groups & Sites
Exhibition
Project Ideas
Languages

// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>


// Modified for Arudino by djmatic

int val = 0;
char code[10];
int bytesread = 0;
void setup() {

PARTICIPATE
- Suggestions
- Formatting guidelines
- All recent changes

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
}

- PmWiki
- WikiSandBox training

void loop() {

- Basic Editing
- Cookbook (addons)

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
}
}

- Documentation index
- Drone with Arduino
- Thermostat with Arduino

}
// extra stuff
// digitalWrite(2, HIGH);

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

// deactivate RFID reader

pdfcrowd.com

another case using SoftwareSerial rxPin=8


- Arduino Digital pin 8 to RFID TX
- Arduino GND to RFID GND
- Arduino Digital pin 2 to RFID enable
- Arduino +5V to RFID Vcc pin.
// Modified by Worapoht K.
#include <SoftwareSerial.h>
int val = 0;
char code[10];
int bytesread = 0;
#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8
void setup()
{
Serial.begin(2400);
pinMode(2,OUTPUT);
digitalWrite(2, LOW);

// Hardware serial for Monitor 2400bps


// Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
// Activate the RFID reader

void loop()
{
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
RFID.begin(2400);
if((val = RFID.read()) == 10)
{
// check for header
bytesread = 0;
while(bytesread<10)
{ // read 10 digit code
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
bytesread++;
// ready to read next digit
}

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

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;
delay(500);
// wait for a second
}
}

Share

NEWSLETTER
Enter your email to sign up

2014 Arduino

Copyright Notice

open in browser PRO version

Contact us

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

S-ar putea să vă placă și