The Servo-Based Door Lock System project teaches you how to create a smart security solution that uses a Servo Motor to control door access electronically. This project combines mechanical control with Arduino logic to build an intelligent locking mechanism.
In this project, a Servo Motor controls the door lock position. A push button allows authorized users to unlock the door. Arduino manages the servo movement between locked and unlocked states with automatic re-locking after a set duration.
When the door is locked, the servo holds the lock in the closed position. When an authorized person presses the button, the servo rotates to unlock the door. After ten seconds, the servo automatically returns to the locked position, ensuring the door remains secure.
This project teaches Servo Mechanical Control, Access Control Logic, Timed Locking Mechanisms, Security System Integration, and Smart Lock Applications.
By finishing this project, you’ll know how electronic door locks work in smart homes, office buildings, secure facilities, and automated access control systems.
To build this circuit, collect these specific items from your kit:
Arduino Uno × 1, Breadboard × 1, Servo Motor (SG90) × 1, Push Button × 1, 10kΩ Resistor × 1, Indicator LEDs × 2, 220Ω Resistor × 2, Jumper Wires × 8, USB Cable × 1
Connect the Arduino GND pin to the negative rail of the breadboard. This creates a shared ground connection that provides a common electrical reference point for your entire circuit system.
Connect the brown ground wire of the Servo Motor directly to the breadboard negative rail. This completes the ground circuit path and ensures proper servo operation and signal stability.
Connect the red power wire of the Servo Motor directly to Arduino 5V. This supplies the necessary voltage to power the Servo Motor electromagnet and mechanical components reliably.
Connect the orange signal wire of the Servo Motor to Arduino Pin 9. This digital pin sends PWM control signals that position the servo arm at specific angles for lock control.
Place the push button on the breadboard across the center gap. Connect one side to Arduino Pin 6 and connect the other side to the breadboard ground rail for simple button operation.
Connect one end of the 10kΩ resistor to Arduino Pin 6 and the other end to Arduino 5V. This pull-up resistor ensures reliable button press detection and prevents floating pin issues.
Connect the red indicator LED anode to Arduino Pin 3 through a 220Ω resistor. Connect its cathode to ground. This LED visually indicates when the door is in the locked state.
Connect the green indicator LED anode to Arduino Pin 4 through a 220Ω resistor. Connect its cathode to ground. This LED visually indicates when the door is in the unlocked state.
Check all servo, button, and LED connections before uploading your code. Ensure the servo can rotate freely without obstruction and verify all power and ground connections are secure.
Important: Mount the Servo Motor securely so it can control the door lock mechanism without slipping or shifting during operation. Proper mechanical attachment is essential for reliable locking.
In setup(), Arduino attaches the Servo object to Pin 9 for motor control. All LED pins and button pins are configured as outputs and inputs respectively. The servo starts at the locked position.
The program continuously checks if the unlock button is pressed using digitalRead(Pin 6). When the button transitions from HIGH to LOW, the unlock sequence begins and the system activates.
When the button is pressed, Arduino moves the servo to 180 degrees representing the unlocked position. The green LED turns on and the red LED turns off, providing clear visual indication of status.
During operation, the system displays door status on the Serial Monitor with countdown timer information. When locked, it shows “DOOR LOCKED – SECURE” and when unlocked displays the remaining time.
After uploading your code, here is what happens.
At startup, the servo positions at zero degrees and locks the door. The red LED illuminates indicating locked status. When you press the unlock button, the servo rotates to 180 degrees. The green LED turns on and the red LED turns off. After ten seconds automatically pass, the servo returns to zero degrees. The red LED illuminates again and the door becomes locked.
Servo Does Not Move :- Verify that the signal wire connects to Pin 9 and check that the servo receives proper 5V power. Confirm that the servo is initialized in setup() with the correct Arduino pin number assignment.
Button Press Does Not Trigger Unlock :- Check that the button connects to Pin 6 and verify the pull-up resistor is between Pin 6 and 5V. Ensure your button press detection logic correctly identifies the button state change event.
Door Does Not Auto-Lock After Timer Expires :- Check the timer duration value in your code equals ten seconds. Verify that the servo movement command to zero degrees is included after the timer completes. Test with shorter timer for easier testing.
LEDs Do Not Show Lock Status :- Check that the LED anodes connect through resistors to the correct pins. Verify LED cathodes connect to ground. Test each LED individually to ensure they are functional and properly oriented.
Servo Arm Does Not Reach Full Rotation :- Verify the angle values in your code range from zero to 180 degrees. Check that the servo horn is securely attached. Ensure the servo is not mechanically obstructed or blocked.
By finishing this project, you now know :-
How servo motors respond to PWM control signals for precise mechanical positioning. You understand how to implement timed automation sequences for automatic locking mechanisms. You learned to create security status indicators using visual feedback with LEDs. You discovered how to coordinate multiple components including servos, buttons, and displays into one integrated system. You mastered the fundamental concepts required to build practical smart lock applications for real-world security needs.
In Day 24, you’ll learn how to build an Automatic Gate System that opens and closes using an ultrasonic sensor to detect vehicles, completing Stage 4 Smart Automation projects. You will integrate distance sensing with servo control to create a fully autonomous gate system.