Deviation’s from Boredom

User manual not included

RFID Locker

with 3 comments

locker

So, I had this old Lions locker that was collecting dust (I got it for Christmas when I was 9). I also happened to have all the parts that I needed to turn this into an RFID safe. AND since I wasn’t too keen on tearing apart the molding around any of the real doors I had access to – I decided to turn this into my next project.

rfid

I ended up using the parallax RFID reader that I had laying around in order to identify whoever was going to access the safe. The reader isn’t the greatest peice of electronics that I’ve used, but it was relatively cheap and readily available.

lock

The locking mechanism is made up of a cheap $5 sliding bolt that I got at my local Lowes. Actually – the servo is also a a relatively inexpensive piece, seeing as it is a cheap hobby servo that I bought for $10 from sparkfun.com.

I used a boarduino (Arduino clone) from Adafruit Industries in order to drive the servo and Parallax RFID.

Here’s the code I used:


#include <Servo.h>

int state = 1;

int val = 0;
char code[10];
int bytesread = 0;
int ledRed = 6;
int ledGreen = 7;

Servo myservo;

void setup() {

Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
pinMode(4,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
pinMode(ledRed,OUTPUT); // Set digital pin 13 as OUTPUT to confirm correct RFID badge
pinMode(ledGreen,OUTPUT);

myservo.attach(9);
myservo.write(1);

digitalWrite(4, LOW); // Activate the RFID reader
}

void loop() {
digitalWrite(4, LOW);
if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 10) { // check for header
bytesread = 0;
while(bytesread 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
}
}

Serial.print(code);

validateRFID(code);

bytesread = 0;
delay(500); // wait for a second
}
}
}

void validateRFID(char* i) {
digitalWrite(4, HIGH);
if(strncmp(i,"0F03042D62", 10) == 0) {
if (state == 0){
myservo.write(1);
digitalWrite(ledRed, HIGH);
state = 1;
delay(5000);
digitalWrite(ledRed, LOW);
}
else if (state == 1){
myservo.write(65);
digitalWrite(ledGreen, HIGH);
state = 0;
delay(5000);
digitalWrite(ledGreen, LOW);
}
}
else{
digitalWrite(ledRed, HIGH);
delay(2000);
digitalWrite(ledRed, LOW);
}

}

I can’t take complete credit for this code – some of it is remnant from the example RFID code that can be found on the Arduino playground.

Advertisement

Written by srcasadei

April 7, 2009 at 6:47 am

Posted in Uncategorized

Tagged with ,

3 Responses

Subscribe to comments with RSS.

  1. [...] Srcasadei made a cool RFID locker… So, I had this old Lions locker that was collecting dust (I got it for Christmas when I was 9). I also happened to have all the parts that I needed to turn this into an RFID safe. AND since I wasn’t too keen on tearing apart the molding around any of the real doors I had access to – I decided to turn this into my next project. The locking mechanism is made up of a cheap $5 sliding bolt that I got at my local Lowes. Actually – the servo is also a a relatively inexpensive piece, seeing as it is a cheap hobby servo that I bought for $10 from sparkfun.com. I used a boarduino (Arduino clone) from Adafruit Industries in order to drive the servo and Parallax RFID. Filed under: random — by adafruit, posted April 10, 2009 at 2:49 pm [...]

  2. Nice project, although I can think of teams other then the Lions to cheer for ;)

    thecapacity

    April 10, 2009 at 10:00 pm

    • Haha – very true. Its a real disappointment too – A lot of people (including myself) have completely lost interest in the sport due to the lack of interesting games.

      srcasadei

      April 11, 2009 at 4:26 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.