Build a Miniature Smart Home with Automatic Garage, Light Curtains & RFID Door Lock

Build a Miniature Smart Home with Automatic Garage, Light Curtains & RFID Door Lock | Arduino Robotics for Kids
🏠

Build a Miniature Smart Home with
Auto Garage · Light Curtains · RFID Door Lock

A hands-on Arduino robotics project where you build a tiny house where the garage opens by itself, curtains pull back when the sun rises, and only a special card can unlock the front door!

🎓 Intermediate ⏱️ 4–6 Hours 🔧 3 Servo Motors 📡 RFID + LDR + IR Sensors 💻 Full Arduino Code

1Project Overview — What Does It Do?

Imagine walking up to your tiny house and the garage door slides up automatically, the curtains inside pull back as morning light floods in, and only people with the right RFID card can open the front door. That's exactly what we're building here — a miniature model home loaded with real working sensors and servo motors, all controlled by a single Arduino Uno!

🚗
Auto Garage Door

An IR sensor detects a "car" approaching and the servo lifts the door open, then closes it after the car passes.

🌅
Light-Sensing Curtains

An LDR (light sensor) watches for bright light. When it gets bright, the curtains open. When it gets dark, they close.

🔑
RFID Door Lock

Tap the right card on the RFID reader and the door servo unlocks. The wrong card? Nothing opens!

🚘
Garage Bay

IR sensor + Servo A

🪟
Living Room

LDR sensor + Servo B

🚪
Front Door

RFID reader + Servo C

🧠
Control Brain

Arduino Uno + Breadboard

🧠 Real-world connection: Real smart homes use these exact same ideas — motion sensors open doors, light sensors adjust blinds, and RFID badges unlock office buildings. You're building the miniature version!

2Materials You'll Need

🖥️ Electronics

Arduino Uno
SG90 Servo Motor
MFRC522 RFID Module + Card + Fob
LDR (light dependent resistor)
IR Proximity Sensor Module
Red LED
Green LED
220Ω resistor
10kΩ resistor (LDR voltage divider)
Breadboard
Jumper wires (male-to-male)
USB cable for Arduino

🏠 House Frame

Cardboard or foam board (A3 size)
Popsicle sticks / craft sticks
Small fabric pieces (for curtains)
Hot glue gun (adult supervised)
Scissors, ruler, pencil
Paint or markers to decorate
🔒 Adult Help Needed: Ask a grown-up to help with the hot glue gun, cutting foam board, and soldering (if needed). Electronics are safe at 5V but always connect power last after checking all wires!

3Building the Miniature House Frame

Before the electronics, we need a house! Keep it simple — a basic box shape about 30cm wide × 25cm deep × 20cm tall works perfectly.

1
Cut your walls. Cut four rectangular panels from foam board for the front, back, and two side walls. Cut a floor piece too.
2
Cut the openings. On the front wall, cut a large rectangular opening for the garage (about 8cm wide × 6cm tall) and a smaller door opening (4cm × 7cm) next to it.
3
Cut window openings in the side wall where the curtains will hang inside.
4
Glue the walls together with hot glue. Let it set for a few minutes before adding any electronics.
5
Decorate! Paint the house, draw bricks, add a roof made of folded cardboard — make it your own before the electronics go in.
6
Mount your servos in position: Servo A at the top of the garage opening (to lift the door), Servo B at the top of the window (to pull the curtains), and Servo C behind the front door.

4Feature 1 — Automatic Garage Door

An IR proximity sensor sits at the base of the garage entrance. When a toy car (or your finger!) breaks the sensor's beam, it tells the Arduino to swing Servo A upward, lifting the garage door. After a short delay, the door comes back down.

How the Garage Door Is Made

  • Cut a piece of cardboard to exactly fit the garage opening.
  • Glue one edge of the door to the servo arm so when the servo rotates, the door lifts up.
  • 0° = door fully closed  |  90° = door fully open.
  • The IR sensor module mounts flat at floor level, pointing across the driveway entrance.
🚗 Fun fact: Real garage doors use similar sensors — infrared beams — to make sure the door doesn't close on a person or pet. Our tiny version uses the same idea in miniature!

Wiring — Garage IR Sensor + Servo A

ComponentPin on ComponentArduino Pin
IR SensorVCC5V
IR SensorGNDGND
IR SensorOUTDigital Pin 4
Servo A (Garage)Signal (Orange)Digital Pin 9
Servo AVCC (Red)5V
Servo AGND (Brown)GND

5Feature 2 — Light-Sensing Curtains

An LDR (Light Dependent Resistor) sits in a window of the house. In the dark the LDR has high resistance; in bright light its resistance drops. By measuring this with the Arduino's analog input, we can tell if it's day or night — and move the curtain servo accordingly.

How the Curtains Are Made

  • Cut two small fabric rectangles (or thin cardstock strips) that are the same width as your window opening.
  • Each strip attaches to a thread, and the thread wraps around the servo arm. When the servo turns, it winds up the thread and pulls the curtain open.
  • A small loop of thread tied to a fixed point pulls the curtain back closed when the servo returns.
💡 LDR Voltage Divider Tip: Connect the LDR between 5V and Analog Pin A0, and place a 10kΩ resistor between A0 and GND. This creates a "voltage divider" — when light hits the LDR, the voltage at A0 rises. Arduino reads this change and decides when it's light enough to open the curtains.

Wiring — LDR + Servo B

ComponentPin / LegArduino Pin
LDRLeg 15V
LDRLeg 2Analog A0 & 10kΩ to GND
Servo B (Curtains)Signal (Orange)Digital Pin 10
Servo BVCC (Red)5V
Servo BGND (Brown)GND

6Feature 3 — RFID Keycard Door Lock

The MFRC522 RFID module uses radio waves to read tiny chips hidden inside cards and key fobs. Every card has a unique ID number — like a fingerprint. We store the "allowed" card ID in the code and compare it each time a card is scanned. Right card → servo unlocks door + green LED. Wrong card → red LED blinks.

How the Door Lock Works

  • Servo C sits behind the front door with a small cardboard "bolt" attached to its arm.
  • When locked, the bolt sticks out horizontally and blocks the door from opening.
  • When the correct card is scanned, the servo rotates 90° to pull the bolt back, and the door can swing open.
  • After 3 seconds, the servo returns and the door is locked again automatically.
🏨 Real-world link: Hotel key cards, office badges, and contactless bus passes all work using RFID — the exact same technology as your little door lock!

Wiring — MFRC522 RFID + Servo C

MFRC522 PinArduino Pin
SDA (SS)Digital 10 — wait! we use Pin 8 here since Pin 10 is for Servo B
SCKDigital 13
MOSIDigital 11
MISODigital 12
GNDGND
RSTDigital 7
3.3V3.3V (NOT 5V — the RFID module runs on 3.3V)
ComponentPinArduino Pin
Servo C (Door Lock)Signal (Orange)Digital Pin 6
Servo CVCC (Red)5V
Servo CGND (Brown)GND
Green LED (+)→ 220Ω → Digital Pin 2
Red LED (+)→ 220Ω → Digital Pin 3
Both LEDs (–)CathodeGND
⚡ Important: The MFRC522 MUST connect to the Arduino's 3.3V pin — never 5V! Connecting it to 5V will permanently damage the module.

7Full Wiring Quick Reference

📍
Pin 2Green LED
📍
Pin 3Red LED
📍
Pin 4IR Sensor OUT
📍
Pin 6Servo C (Door)
📍
Pin 7RFID RST
📍
Pin 8RFID SS/SDA
📍
Pin 9Servo A (Garage)
📍
Pin 10Servo B (Curtain)
📍
Pin 11RFID MOSI
📍
Pin 12RFID MISO
📍
Pin 13RFID SCK
📍
A0LDR Signal
ARDUINO UNO SERVO A Garage Door Pin 9 SERVO B Curtains Pin 10 SERVO C Door Lock Pin 6 IR SENSOR Garage Detect Pin 4 LDR Light Sensor A0 MFRC522 RFID Reader SPI Bus GREEN LED Access OK Pin 2 RED LED Access Denied Pin 3 --- Signal wires (dashed lines) all share 5V and GND via breadboard

8The Complete Arduino Code

Before uploading, you need to install two libraries in the Arduino IDE: Servo (built-in) and MFRC522 (search for it in Sketch → Include Library → Manage Libraries).

📋 Step before uploading: You need to find your card's UID first! Upload only the DumpInfo example from the MFRC522 library, scan your card, copy the UID from the Serial Monitor, then paste it into the code below.
// ════════════════════════════════════════════════
//  🏠 Miniature Smart Home
//  Features: Auto Garage · Light Curtains · RFID Lock
//  Arduino Uno + SG90 Servos + MFRC522 + LDR + IR
// ════════════════════════════════════════════════

#include <Servo.h>
#include <SPI.h>
#include <MFRC522.h>

// ── PIN DEFINITIONS ──────────────────────────────
const int PIN_IR        = 4;
const int PIN_SERVO_A   = 9;   // Garage door
const int PIN_SERVO_B   = 10;  // Curtains
const int PIN_SERVO_C   = 6;   // Door lock
const int PIN_LDR       = A0;
const int PIN_LED_GREEN = 2;
const int PIN_LED_RED   = 3;
const int RFID_SS       = 8;
const int RFID_RST      = 7;

// ── SERVO OBJECTS ─────────────────────────────────
Servo garageServo;
Servo curtainServo;
Servo doorServo;

// ── RFID OBJECT ───────────────────────────────────
MFRC522 rfid(RFID_SS, RFID_RST);

// ── YOUR CARD UID ─ Replace with your card's UID ──
byte allowedUID[4] = {0xAB, 0xCD, 0xEF, 0x12};

// ── THRESHOLDS ────────────────────────────────────
const int LIGHT_THRESHOLD = 600; // 0-1023; tune for your room

// ── SERVO ANGLES ──────────────────────────────────
const int GARAGE_CLOSED = 0;
const int GARAGE_OPEN   = 90;
const int CURTAIN_CLOSED = 0;
const int CURTAIN_OPEN   = 120;
const int DOOR_LOCKED    = 0;
const int DOOR_UNLOCKED  = 90;

// ── STATE VARIABLES ───────────────────────────────
bool garageOpen   = false;
bool curtainOpen  = false;
bool doorUnlocked = false;
unsigned long garageTimer = 0;
unsigned long doorTimer   = 0;

// ════════════════════════════════════════════════
void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();

  garageServo.attach(PIN_SERVO_A);
  curtainServo.attach(PIN_SERVO_B);
  doorServo.attach(PIN_SERVO_C);

  pinMode(PIN_IR,        INPUT);
  pinMode(PIN_LED_GREEN, OUTPUT);
  pinMode(PIN_LED_RED,   OUTPUT);

  // Start in closed/locked position
  garageServo.write(GARAGE_CLOSED);
  curtainServo.write(CURTAIN_CLOSED);
  doorServo.write(DOOR_LOCKED);

  Serial.println("🏠 Smart Home Ready!");
}

// ════════════════════════════════════════════════
void loop() {
  handleGarage();
  handleCurtains();
  handleRFID();
  handleAutoClose();
}

// ── GARAGE DOOR ───────────────────────────────────
void handleGarage() {
  bool carDetected = (digitalRead(PIN_IR) == LOW); // IR LOW = object detected

  if (carDetected && !garageOpen) {
    garageServo.write(GARAGE_OPEN);
    garageOpen = true;
    garageTimer = millis();
    Serial.println("🚗 Car detected — Garage OPEN");
  }
}

// ── LIGHT-SENSING CURTAINS ────────────────────────
void handleCurtains() {
  int lightLevel = analogRead(PIN_LDR);

  if (lightLevel > LIGHT_THRESHOLD && !curtainOpen) {
    curtainServo.write(CURTAIN_OPEN);
    curtainOpen = true;
    Serial.println("🌅 Bright! Curtains OPENING");
  } else if (lightLevel <= LIGHT_THRESHOLD && curtainOpen) {
    curtainServo.write(CURTAIN_CLOSED);
    curtainOpen = false;
    Serial.println("🌙 Dark. Curtains CLOSING");
  }
}

// ── RFID DOOR LOCK ────────────────────────────────
void handleRFID() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;

  bool authorized = true;
  for (byte i = 0; i < 4; i++) {
    if (rfid.uid.uidByte[i] != allowedUID[i]) {
      authorized = false;
      break;
    }
  }

  if (authorized) {
    doorServo.write(DOOR_UNLOCKED);
    doorUnlocked = true;
    doorTimer = millis();
    digitalWrite(PIN_LED_GREEN, HIGH);
    Serial.println("✅ Access GRANTED — Door UNLOCKED");
  } else {
    digitalWrite(PIN_LED_RED, HIGH);
    delay(200); digitalWrite(PIN_LED_RED, LOW);
    delay(200); digitalWrite(PIN_LED_RED, HIGH);
    delay(200); digitalWrite(PIN_LED_RED, LOW);
    Serial.println("❌ Access DENIED");
  }

  rfid.PICC_HaltA();
}

// ── AUTO-CLOSE TIMERS ─────────────────────────────
void handleAutoClose() {
  unsigned long now = millis();

  if (garageOpen && (now - garageTimer > 4000)) {
    garageServo.write(GARAGE_CLOSED);
    garageOpen = false;
    Serial.println("🔒 Garage CLOSING");
  }

  if (doorUnlocked && (now - doorTimer > 3000)) {
    doorServo.write(DOOR_LOCKED);
    doorUnlocked = false;
    digitalWrite(PIN_LED_GREEN, LOW);
    Serial.println("🔒 Door RE-LOCKED");
  }
}
🧠 How millis() works: Instead of delay() which freezes the Arduino, we use millis() to check how much time has passed — like peeking at a clock. This way the garage timer, door timer, and RFID scanner all run at the same time without blocking each other!

9Testing Your Smart Home

🚗 Test 1 — Garage Door

Hold a toy car (or your finger) in front of the IR sensor at the garage entrance. The servo should rotate upward within a second, and after 4 seconds it should come back down on its own.

🌅 Test 2 — Light Curtains

Shine a torch or phone flashlight at the LDR. The curtains should open. Cover the LDR with your hand (go dark) and the curtains should close. Adjust LIGHT_THRESHOLD in the code if needed — open the Serial Monitor (9600 baud) to see the actual LDR reading and tune it perfectly.

🔑 Test 3 — RFID Door

Tap your allowed card on the RFID reader — the green LED should light up and the door servo should unlock for 3 seconds. Try a different card or fob — the red LED should blink twice and nothing should open.

10Awesome Upgrades to Try

  • 🔔 Doorbell buzzer: Add a piezo buzzer and a button outside the front door to ring a little chime inside the house.
  • 💡 Smart lights: Add LEDs inside each room, and use a relay module to flip them on/off based on time of day (with a real-time clock module).
  • 📱 Bluetooth control: Add an HC-05 Bluetooth module so you can open the garage or unlock the door from a phone app.
  • 🌡️ Temperature display: Add a DHT11 sensor and a small LCD to show the temperature and humidity inside your tiny home.
  • 🏊 Garden sprinkler: Add a small pump and soil moisture sensor so the garden waters itself when the soil gets dry!
  • 📹 Security camera: Connect an ESP32-CAM module so you can view a live video feed of the house entrance on your phone.
🏠 You just built a real working smart home in miniature — that's engineering, electronics, and code all in one! Keep building, keep experimenting. The next upgrade is just one idea away. 🔧✨

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course