This website uses 'cookies' to give you the best, most relevant experience. Using this website means you're happy with this. read more Accept & Close
Start Games
Do It Yourself
DIY & Home Improvement

Arduino RFID lock with RC522 - MIFARE protocol 13.56 mhz

Arduino RFID lock with RC522 - MIFARE protocol 13.56 mhz
Arduino RFID lock with RC522 - MIFARE protocol 13.56 mhz
I will show you how to easily make a RFID lock. I will use
Arduino UNO, RFID RC522 (MIFARE protocol).

Step 1: Components

Step 2: Schematic

Schematic of Arduino RFID lock
Schematic of Arduino RFID lock

Step 3: Software

At the beginning we import all the needed libraries.
#include <SPI.h> #include <MFRC522.h> #include <Servo.h> #include <Adafruit_NeoPixel.h>
Then we configure and initialize:
UART speed
We initiate rc522
We set the servo to zero
void setup() { Serial.begin(115200); SPI.begin(); mfrc522.PCD_Init(); Serial.println("For more: http://geek.adachsoft.com"); Serial.println("Arduino RFID lock"); Serial.println(""); myservo.attach(SERVO_PIN); myservo.write( 0 ); pixels.begin(); pixels.setPixelColor(0, 32, 32, 32); pixels.show(); delay(500); pixels.setPixelColor(0, 0, 0, 0); pixels.show(); }
After we read the UID tag, we compare it with the proper UID.
If the UID is the same then start the servo.
if( content == "77-39-50-39" ){ Serial.println("Authorized access"); myservo.write( 90 ); pixels.setPixelColor(0, 0, 32, 0); pixels.show(); delay(1000); myservo.write( 0 ); pixels.setPixelColor(0, 0, 0, 0); pixels.show(); }else{ Serial.println("Access denied"); pixels.setPixelColor(0, 32, 0, 0); pixels.show(); delay(500); pixels.setPixelColor(0, 0, 0, 0); pixels.show(); }
Download source code: RFID_with_servo.ino



Step 4: End and checking