This is an old revision of the document!
A brief presentation of my project:
Block Diagram:
Hardware Modules:
- Arduino UNO Acts as the central controller, reading input data from the RFID reader and controlling output devices like the servo motor, LCD, and LEDs.
- RFID Module (RC522) Scans RFID cards using SPI communication. The Arduino compares the scanned UID with a predefined list of authorized UIDs.
- Servo Motor Simulates a door latch. It rotates to unlock the door when a valid card is detected and locks it again afterward.
- LCD with I2C Module Displays access status messages such as “Access Granted” or “Access Denied”.
- LEDs (Green and Red) Provide quick visual feedback:
- Iron Latch Connected to the servo, simulates the actual door locking mechanism.
Softare Flow
1. The user scans an RFID card using the RC522 module.
2. The UID is sent to the Arduino via SPI.
3. The Arduino checks if the UID matches one from the authorized list: If authorized: The servo motor rotates to unlock the latch. Green LED turns on. LCD displays: Access Granted. If unauthorized: Servo remains in locked position. Red LED turns on. LCD displays: Access Denied.
4. After a short delay, the system resets the servo to the locked position and turns off the LED.
Component | Quantity | Arduino Pin Connections | Description / Role |
—————————— | ———- | ——————————————————————————– | ——————————————— |
Arduino Uno | 1 | – | Central microcontroller |
RFID-RC522 | 1 | VCC→3.3 V, GND→GND, SDA→D10, SCK→D13, MOSI→D11, MISO→D12, RST→D9 | Reads RFID card UID via SPI |
SG90 Servo Motor | 1 | VCC→5 V, GND→GND, Signal→D3 | Rotates to simulate locking/unlocking |
16×2 LCD w/ I²C Backpack | 1 | VCC→5 V, GND→GND, SDA→A4, SCL→A5 | Displays access status messages |
Green LED | 1 | Anode→D6 (via 220 Ω), Cathode→GND | Indicates “Access Granted” |
Red LED | 1 | Anode→D7 (via 220 Ω), Cathode→GND | Indicates “Access Denied” |
220 Ω Resistors | 2 | In series with each LED | Limits current through LEDs |
Iron Latch / Metal Bar | 1 | Connected mechanically to the servo | Simulates physical locking mechanism |
Breadboard | 1 | – | Used for prototyping connections |
Jumper Wires | ~25 | – | Connects components to the Arduino |
This firmware was developed in PlatformIO (VS Code) with the *Arduino* framework, but it can be uploaded from the regular Arduino IDE as well.
➤ 1. Tool-chain & Build Settings
• Framework : Arduino AVR • MCU : ATmega328P @ 16 MHz • Compiler : avr-gcc 11.x (packaged with PlatformIO) • Upload : avrdude, 115 200 baud • Debug : Serial (9600 baud) – progress messages when scanning cards
➤ 2. External Libraries
➤ 3. Core Ideas & Algorithms
Concept | Implementation highlight |
— | — |
Servo PWM | `servoInit()` configures Timer-1 in *Fast PWM, ICR1=40000* → 50 Hz. `setServoPosition()` maps 0–180 ° to 2–4 ms pulse (OCR1A). |
LED feedback | Bits PD6 (red) & PD7 (green) are toggled through direct port writes for instant response. |
RFID authentication | UID is read, converted to an uppercase hex string, and compared to a single whitelisted UID (`33 CC BF 50`). |
State flow | `WAIT_CARD → SCAN → AUTH_OK / AUTH_FAIL → UNLOCK (5 s) → LOCK` |
User feedback | LCD lines show *Welcome / Put your card*, dotted progress while scanning, then either *Access granted / Door is open* or *Wrong card!* |
➤ 4. Principal Functions
servoInit() – sets up Timer-1 for 50 Hz PWM
setServoPosition() – writes a new duty (0–180 °) to OCR1A
loop() – handles UI text, card scan, decision, LED + servo actions
rfid.PICC_HaltA() – gracefully halts the tag after each transaction
All logic resides in a single file (`src/main.cpp` in PlatformIO).
No dynamic memory or interrupts are used; timing is managed with short, fixed `delay()` calls for simplicity.
Fişierele se încarcă pe wiki folosind facilitatea Add Images or other files. Namespace-ul în care se încarcă fişierele este de tipul :pm:prj20??:c? sau :pm:prj20??:c?:nume_student (dacă este cazul). Exemplu: Dumitru Alin, 331CC → :pm:prj2009:cc:dumitru_alin.