background image

/*****************************

 

     

RFID

­

powered

 

lockbox

 

This

 

sketch

 

will

 

move

 

a

 

servo

 

when

 

a

 

trusted

 

tag

 

is

 

read

 

with

 

the

  

ID

­

12/ID

­

20

 

RFID

 

module

 

Pinout

 

for

 

SparkFun

 

RFID

 

USB

 

Reader

 

Arduino

 ­­­­­ 

RFID

 

module

 

5V

            

VCC

 

GND

           

GND

 

D2

            

TX

 

Pinout

 

for

 

SparkFun

 

RFID

 

Breakout

 

Board

 

Arduino

 ­­­­­ 

RFID

 

module

 

5V

            

VCC

 

GND

           

GND

 

D2

            

D0

 

Connect

 

the

 

servo's

 

power,

 

ground,

 

and

 

signal

 

pins

 

to

 

VCC,

 

GND,

 

and

 

Arduino

 

D9

 

If

 

using

 

the

 

breakout,

 

you

 

can

 

also

  

put

 

an

 

LED

 

&

 

330

 

ohm

 

resistor

 

between

  

the

 

RFID

 

module's

 

READ

 

pin

 

and

 

GND

 

for

  

a

 

"card

 

successfully

 

read"

 

indication

 

by

 

acavis,

 

3/31/2015

 

Inspired

 

by

 

&

 

partially

 

adapted

 

from

 

http://bildr.org/2011/02/rfid

­

arduino/

 

******************************/

#include

 

<SoftwareSerial.h>

#include

 

<Servo.h>

//

 

Choose

 

two

 

pins

 

for

 

SoftwareSerial

SoftwareSerial

 

rSerial(2,

 

3);

 

//

 

RX,

 

TX

//

 

Make

 

a

 

servo

 

object

Servo

 

lockServo;

 

//

 

Pick

 

a

 

PWM

 

pin

 

to

 

put

 

the

 

servo

 

on

const int servoPin

 

= 9;

//

 

For

 

SparkFun's

 

tags,

 

we

 

will

 

receive

 

16

 

bytes

 

on

 

every

//

 

tag

 

read,

 

but

 

throw

 

four

 

away.

 

The

 

13th

 

space

 

will

 

always

//

 

be

 

0,

 

since

 

proper

 

strings

 

in

 

Arduino

 

end

 

with

 

0

//

 

These

 

constants

 

hold

 

the

 

total

 

tag

 

length

 

(tagLen)

 

and

//

 

the

 

length

 

of

 

the

 

part

 

we

 

want

 

to

 

keep

 

(idLen),

//

 

plus

 

the

 

total

 

number

 

of

 

tags

 

we

 

want

 

to

 

check

 

against

 

(kTa

gs)
const int tagLen

 

= 16;

const int idLen

 

= 13;

const int kTags

 

= 4;

//

 

Put

 

your

 

known

 

tags

 

here!

char knownTags[kTags][idLen]

 

= {

"111111111111",
"444444444444",
"555555555555",

Page 7 of 10

Summary of Contents for RFID Starter Kit

Page 1: ...reader to a computer Recommended Reading The ID 12LA module has a serial output If you ve never worked with a serial device or a terminal program before you might want to take a look at these tutorial...

Page 2: ...sy of EPC RFID Passive tags like the ones included with this kit gather electromagnetic energy from the card reader and use that to transmit their unique serial number More sophisticated tags may have...

Page 3: ...ing features 1 A buzzer that sounds when a card is read If you are using the RFID kit in a stealth application you can disconnect the buzzer by removing the blob of solder on the Buzz jumper 2 A card...

Page 4: ...Serial Monitor The default terminal settings 9600 baud no line ending are fine The monitor should be blank Wave a card over the reader You should hear a beep and see something like this Now we ll do...

Page 5: ...an again Now the bread is visible That s cool right Example Project As fun as it is to watch your cards pop up in the serial terminal you d probably like to do something with all this power The exampl...

Page 6: ...pins on the RFID USB Reader to the Arduino s 5V GND and D2 pins and connect the servo to 5V GND and D9 Upload the below code open your Serial Monitor by going to Tools Serial Monitor and start scanni...

Page 7: ...y adapted from http bildr org 2011 02 rfid arduino include SoftwareSerial h include Servo h Choose two pins for SoftwareSerial SoftwareSerial rSerial 2 3 RX TX Make a servo object Servo lockServo Pick...

Page 8: ...ing the Arduino can read faster than the ID module c an deliver if rSerial available tagLen tag true if tag true while rSerial available Take each byte out of the serial buffer one at a tim e readByte...

Page 9: ...next tag read for int c 0 c idLen c newTag c 0 This function steps through both newTag and one of the know n tags If there is a mismatch anywhere in the tag it will r eturn 0 but if every character in...

Page 10: ...the module removed so you can read the silk Resources and Going Further You can use the SparkFun RFID Reader Kit and an Arduino to control access to just about anything Instead of moving a servo how a...

Reviews: