Introduction: Arduino RFID Lock Box

Hi, today I will be showing you how to make a RFID Lock box.

Step 1: Preperation

You will need

1x wooden box -

1x Parallax READ-ONLY RFID scanner -

1x Arduino Uno -

1x Mini Hobby Servo -

1x RGB LED -

1x Battery box (five double a's)

Also you will need a Dremel

Step 2: Wiring the Electronics

Place your components like this:

RFID SOUT goes to Arduino RX

RFID EN goes to Arduino D2

RFID +5 goes to Arduino Power

RFID GND goes to Arduino GND

Servo Signal goes to Arduino D9

Servo PWR goes to Arduino Power

Servo GND goes to Arduino GND

LED Blue goes to Arduino D6

LED Red goes to Arduino D5

LED Green goes to Arduino D4

LED GND goes to Arduino GND

Step 3: Program!

Programming time...

Upload this code to your Arduino:

String Master = "A9001513FF"; //MASTER CARD TAG #

//Constants #include #define NumberOfKeys 10 //This defines the amount of keys in the access list #define WAIT_TIME 4000 //Time door will remain open #define BLINKS 2 //The amount of times the indicators blink when blinking is required #define ON_TIME 4000//time in milliseconds the relay stays energized

//External Equipment #define ENABLE 2 //Pin connected to the Enable pin of RFID #define LOCK 9 Servo my; int stat = 0; //Pin that is connected to NPN transistor that energizes lock

//LED Indicators #define OPEN_LIGHT 4 //LED indicator. Indicates the correct key was entered #define DENIED_LIGHT 5 //LED indicator. Indicates the wrong key was entered #define PROGRAMMING_LIGHT 6 //LED indicator. Indicates Programming mode is activated

int val = 0; int bytesread = 0; //Stores the master key used for programming the other keys String empty = "0000000000"; String keyCode; String accessList[NumberOfKeys]; char code[10]; boolean programmingMode,isInAccessList,KeyFound = false;

void setup() { my.attach(9); pinMode(OPEN_LIGHT,OUTPUT); pinMode(DENIED_LIGHT,OUTPUT); pinMode(PROGRAMMING_LIGHT,OUTPUT);

//Generates an array of size corresponding to the size of the access list for(int i = 0;i

Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps

digitalWrite(OPEN_LIGHT,LOW); digitalWrite(DENIED_LIGHT,LOW); digitalWrite(PROGRAMMING_LIGHT,LOW); digitalWrite(ENABLE, LOW); // LOW Activates the RFID reader, HIGH deactivates it


void loop() { /**** EXTRACTION OF DATA FROM CARD ****/ if(Serial.available() > 0) { // if data available from reader if((val = == 10) { // check for header [Header of data = 10] bytesread = 0; while(bytesread<10) { // read 10 digit code if( Serial.available() > 0) { val =; 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 digitalWrite(ENABLE, HIGH); // deactivate the RFID reader for a moment so it will not flood keyCode = code; keyCode = keyCode.substring(0,10); /*** INTERPRETATION OF DATA ***/ //At this point, data was read, and there is a keycode in the keyCode variable if((keyCode == Master) && (programmingMode == false)) {programmingMode = true; digitalWrite(PROGRAMMING_LIGHT,HIGH); } else {if(programmingMode == false) { for(int i = 0;i

} } }

/*** CLEARS DATA FROM BUFFERS TO AVOID DOUBLE READS***/ void flushBuffers(){ while(Serial.available() > 0) //if there is still data remaining in the RFID reader buffer; //read it into arduino buffer Serial.flush(); //then flush it }

/*** RESETTING INDICATORS ***/ void resetIndicators(){ delay(WAIT_TIME); //wait a little flushBuffers(); //clear buffers //return everything to starting position digitalWrite(OPEN_LIGHT,LOW); digitalWrite(DENIED_LIGHT,LOW); digitalWrite(ENABLE,LOW); }

/*** BEHAVIOR OF LED INDICATORS IF A KEY IN THE ACCESS LIST IS SWIPPED ***/ void accessGranted(){ digitalWrite(OPEN_LIGHT,HIGH); my.write(140);//Sends 5V to transistor to energize door lock } /*** BEHAVIOR OF LED INDICATORS IF A KEY THAT'S NOT IN THE ACCESS LIST IS SWIPPED ***/ void accessDenied(){ digitalWrite(DENIED_LIGHT,HIGH); my.write(10); }

/*** BEHAVIOR OF LED INDICATORS IF A NEW KEY IS ENTERED IN THE ACCESS LIST ***/ void newKeyEntered(){ for(int i = 0; i

/*** BEHAVIOR OF LED INDICATORS IF A KEY IS DELETED FROM ACCESS LIST ***/ void keyDeleted(){ for(int i = 0; i

/*** BEHAVIOR OF LED INDICATORS IF ACCESS LIST IS FULL ***/ void listFull(){ for(int i = 0; i

Step 4: Tape It All Together.

Tape it together with duct-tape.

Step 5: Finished!

You are now a proud owner of a DIYArduinoRFIDLock