In modern security systems, door access control is a crucial component that ensures only authorized individuals can enter restricted areas. This project will guide you through designing a basic door access control system using TinkerCAD. We will use an Arduino, an RFID reader, an RFID card, and a servo motor to create a system where access is granted based on the RFID card's credentials.
Materials Needed:
Arduino Uno
RFID Reader (e.g., MFRC522)
RFID Tags/Cards
Servo Motor
Breadboard
Jumper Wires
10kΩ Resistor (for pull-up on the RFID module)
Step 1: Understanding the Components
RFID Reader (MFRC522):
SDA: Serial Data (connects to Arduino's pin 10)
SCK: Serial Clock (connects to Arduino's pin 13)
MOSI: Master Out Slave In (connects to Arduino's pin 11)
MISO: Master In Slave Out (connects to Arduino's pin 12)
RST: Reset (connects to Arduino's pin 9)
GND: Ground (connects to Arduino GND)
VCC: Power Supply (connects to Arduino 5V)
RFID Tags/Cards:
Used to authenticate users. Each card has a unique ID.
Servo Motor:
Used to control the locking mechanism of the door.
Control Pin: Connects to a PWM-capable pin on the Arduino (e.g., pin 6)
Power: Connects to an external 5V power source
Ground: Connects to GND
Step 2: Setting Up the Circuit in TinkerCAD
Arduino Uno: Place the Arduino Uno on the TinkerCAD workspace. This will be the central controller for your access control system.
RFID Reader:
Place the RFID reader on the breadboard.
Connect the SDA pin of the RFID reader to Arduino pin 10.
Connect the SCK pin to Arduino pin 13.
Connect the MOSI pin to Arduino pin 11.
Connect the MISO pin to Arduino pin 12.
Connect the RST pin to Arduino pin 9.
Connect the GND pin to Arduino GND.
Connect the VCC pin to Arduino 5V.
Servo Motor:
Place the servo motor on the breadboard.
Connect the control pin of the servo to Arduino pin 6.
Connect the power pin of the servo to an external 5V power source.
Connect the ground pin of the servo to Arduino GND.
Power: Ensure the Arduino is powered, either through a USB connection or an external power source.
Step 3: Writing the Arduino Code
The Arduino code will read the RFID tag ID, compare it with authorized IDs, and control the servo motor to lock or unlock the door based on the tag's credentials
#include <SPI.h> // Include the SPI library for communication with RFID
#include <MFRC522.h> // Include the RFID library
#include <Servo.h> // Include the Servo library
#define RST_PIN 9 // Reset pin for the RFID reader
#define SS_PIN 10 // Slave Select pin for the RFID reader
#define SERVO_PIN 6 // Pin connected to the servo motor
MFRC522 rfid(SS_PIN, RST_PIN); // Create an MFRC522 instance
Servo doorServo; // Create a Servo instance
// Authorized RFID tag IDs
const String authorizedIDs[] = {
"123456789", // Example RFID ID
"987654321" // Another example RFID ID
};
void setup() {
Serial.begin(9600); // Start serial communication for debugging
SPI.begin(); // Initialize SPI bus
rfid.PCD_Init(); // Initialize RFID reader
doorServo.attach(SERVO_PIN); // Attach the servo to the specified pin
doorServo.write(0); // Start with the door locked (servo at 0 degrees)
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return; // No new RFID card present or failed to read card
}
String tagID = ""; // Variable to store the RFID tag ID
// Convert the UID to a string
for (byte i = 0; i < rfid.uid.size; i++) {
tagID += String(rfid.uid.uidByte[i] < 0x10 ? "0" : "");
tagID += String(rfid.uid.uidByte[i], HEX);
}
tagID.toUpperCase(); // Convert to uppercase
Serial.print("Tag ID: ");
Serial.println(tagID); // Print the tag ID for debugging
// Check if the tag ID is in the list of authorized IDs
bool accessGranted = false;
for (int i = 0; i < sizeof(authorizedIDs) / sizeof(authorizedIDs[0]); i++) {
if (authorizedIDs[i] == tagID) {
accessGranted = true;
break;
}
}
if (accessGranted) {
Serial.println("Access Granted");
doorServo.write(90); // Unlock the door (servo at 90 degrees)
delay(5000); // Keep the door unlocked for 5 seconds
doorServo.write(0); // Lock the door (servo at 0 degrees)
} else {
Serial.println("Access Denied");
}
rfid.PICC_HaltA(); // Halt the RFID card
rfid.PCD_StopCrypto1(); // Stop encryption on the reader
}
Step 4: Simulating the Circuit in TinkerCAD
Start the Simulation: Click the "Start Simulation" button in TinkerCAD. The servo motor should respond based on the RFID tag used.
Testing the System: Simulate different RFID tag readings by adjusting the UID values in the code. Observe how the servo motor moves to unlock or lock the door based on the tag's ID.
Troubleshooting: If the system does not behave as expected, check the connections and ensure the code is correctly uploaded. Verify that the RFID reader is receiving and processing the tag data properly.
Step 5: Enhancing the System
Once you have the basic door access control system working, consider these enhancements:
Multiple Doors: Expand the system to control multiple doors with different access permissions.
User Management: Implement a method to add or remove authorized RFID tags dynamically.
Notification System: Add LEDs or buzzers to provide visual or audible feedback when access is granted or denied.
Remote Access: Integrate with a remote control system or mobile app for access management.
Step 6: Building the Physical Circuit
After successfully simulating the circuit in TinkerCAD, you can build the physical door access control system.
Assemble Components: Transfer the TinkerCAD design to a physical breadboard or custom PCB.
Upload Code: Connect your Arduino to a computer, upload the code, and test the system with real components.
Test and Calibrate: Verify the system’s response with actual RFID tags and adjust the calibration as needed.
Step 7: Expanding the Project
With a working prototype, you can explore further possibilities:
Advanced Security Features: Implement additional security measures such as PIN codes or biometric sensors.
Integration with Building Systems: Connect the access control system to a building's security and automation systems.
Data Logging: Add functionality to log access attempts and maintain a record of who accessed the door and when.
Conclusion
Congratulations on designing and simulating a door access control system using TinkerCAD! This project demonstrates how to integrate RFID technology with an Arduino to create a functional and practical security solution. The skills and concepts learned in this project can be applied to various security and automation applications.
With the foundation you’ve built, you can continue to innovate and develop more advanced and secure systems.
Happy tinkering!
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Commentaires