Arduino UNO RFID Access Control with Servo Lock and LCD Feedback
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit integrates an Arduino UNO microcontroller with an RFID-RC522 module, a servo motor, and an LCD I2C display. The Arduino UNO serves as the central processing unit, controlling the RFID reader for scanning tags, driving the servo motor, and displaying information on the LCD. The RFID-RC522 module is used for reading RFID tags, the servo motor is controlled based on the RFID scans, and the LCD display provides a user interface to display the scanned tag's UID.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
RFID-RC522
- An RFID reader/writer module that operates at 13.56 MHz
- It is commonly used for near-field communication (NFC) or RFID systems.
Servo
- An actuator that can be precisely controlled for angular rotation
- It has three connections: power (VCC), ground (GND), and control signal (pulse).
LCD I2C Display
- A liquid crystal display that uses the I2C bus for communication
- It requires only two data lines (SDA and SCL) for communication, which simplifies the wiring.
Wiring Details
Arduino UNO
3.3Vconnected to RFID-RC522 VCC (3.3V)5Vconnected to Servo VCC and LCD I2C Display SDAGNDconnected to RFID-RC522 GND, Servo GND, and LCD I2C Display SCLA4connected to LCD I2C Display VCCA5connected to LCD I2C Display GNDD13connected to RFID-RC522 SCKD12connected to RFID-RC522 MISOD11connected to RFID-RC522 MOSID10connected to RFID-RC522 SDAD9connected to RFID-RC522 RSTD3connected to Servo pulse
RFID-RC522
VCC (3.3V)connected to Arduino UNO 3.3VRSTconnected to Arduino UNO D9GNDconnected to Arduino UNO GNDIRQ(Not connected)MISOconnected to Arduino UNO D12MOSIconnected to Arduino UNO D11SCKconnected to Arduino UNO D13SDAconnected to Arduino UNO D10
Servo
vccconnected to Arduino UNO 5Vgndconnected to Arduino UNO GNDpulseconnected to Arduino UNO D3
LCD I2C Display
GNDconnected to Arduino UNO A5VCCconnected to Arduino UNO A4SDAconnected to Arduino UNO 5VSCLconnected to Arduino UNO GND
Documented Code
/*RFID tag scan code
* https://srituhobby.com
*/
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10
byte readCard[4];
byte a = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
lcd.setCursor(2, 0);
lcd.print("Put your card");
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return 0;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return 0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Scanned UID");
a = 0;
Serial.println(F("Scanned PICC's UID:"));
for ( uint8_t i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
Serial.print(" ");
lcd.setCursor(a, 1);
lcd.print(readCard[i], HEX);
lcd.print(" ");
delay(500);
a += 3;
}
Serial.println("");
mfrc522.PICC_HaltA();
return 1;
}
This code is designed to run on the Arduino UNO and uses the RFID-RC522 module to scan RFID tags. When a tag is scanned, its UID is displayed on the LCD and printed to the serial monitor. The LiquidCrystal_I2C library is used to control the LCD display via the I2C bus, and the MFRC522 library is used to interface with the RFID module. The code initializes the RFID reader and the LCD display in the setup() function and continuously checks for new RFID tags in the loop() function. When a tag is detected, its UID is read, displayed, and printed.