Smart Mini
Apartment
That Runs Itself
An auto-folding bed, self-opening curtains, a rotating TV, and a sliding wardrobe — all packed into one tiny apartment powered by Arduino! 🏠⚙️
🏗️ What Is a Smart Miniature Apartment?
Micro-apartments are becoming popular in big cities because they use space incredibly cleverly — walls fold into beds, furniture slides and rotates. Your model brings this to life using servo motors controlled by Arduino Mega, replicating each smart mechanism at 1:20 scale.
This is the most complex Arduino build in the MakeMindz series — 6 servo motors, 4 sensors, 2 buttons, and 1 LCD all coordinated by one program. Build it, and you'll understand how real smart apartments are designed!
Real Murphy wall beds use a gas piston mechanism. Yours uses an SG90 servo that pivots a cardboard bed panel up into a wall slot — exact same principle, tiny scale!
A servo pulls a thread connected to both curtain panels. When the servo turns one way, both curtains open. Reverse = close. An LDR triggers them automatically at sunrise!
A servo motor sits under the TV platform and rotates it up to 90°. Press a button and the TV faces the sofa. Press again, it faces the dining table. Just like luxury smart homes!
An SG90 servo with a thread-and-pulley system slides the wardrobe door along a top rail. The door glides open when triggered — perfect space-saving mechanism!
🛒 Full Parts List
Everything available on Amazon India or Robu.in. Budget ~₹3,200 for all four features:
⚡ Circuit Diagram
Six servo motors, one LDR, four buttons, one LCD, and a buzzer — all coordinated by one Arduino Mega:
🔧 Step-by-Step Build Guide
Build the apartment structure first, then install each mechanism one at a time. Test each before moving to the next!
Use foam board (best) or thick cardboard to build a 40cm × 30cm × 25cm miniature apartment with two rooms:
- Floor: One large base plate, 40cm × 30cm
- Walls: Three walls (back, left, right) — 25cm tall. Front is open for viewing
- Partition wall: Divides bedroom (left) from living room (right) at the 20cm mark
- Window openings: Cut 8cm × 6cm windows in the bedroom wall for the curtains
- Wardrobe alcove: In the living room, create a 10cm × 15cm recessed section for the wardrobe
- Ceiling: Loose-fit ceiling panel (removable for easy wiring access)
The Murphy bed mechanism is the most mechanical part of the build:
- Cut a bed panel from foam board: 8cm × 5cm (mattress surface)
- Attach a small hinge along the bottom edge of the bed panel to the wall — the bed pivots here
- Mount the MG90S servo on the wall with its shaft horizontally, 2cm above the hinge
- Glue a short arm (3cm of coffee stirrer) to the servo horn
- Connect the servo arm to the back of the bed panel with a pin or toothpick pivot
- When servo rotates to 90°, the arm pushes the bed panel up and into the wall slot
The curtain mechanism uses a single servo to pull both panels simultaneously:
- Cut two fabric curtain panels (use tissue paper or thin cloth): 4cm × 6cm each
- Hang them from a thin wooden skewer (curtain rod) glued above the window
- Mount the SG90 servo above the window, shaft pointing down, off to one side
- Tie a thread from the left curtain, across to the servo horn, and across to the right curtain
- When servo turns clockwise, it pulls both threads, opening both curtains simultaneously
- Counterclockwise rotation releases thread — curtains close under their own weight (add tiny weights at bottom if needed)
// Sketch → Include Library → Manage Libraries → install: "LiquidCrystal_I2C" // for the status LCD "Servo" // built-in, controls all 4 servos
The complete Arduino Mega program controlling all four features — button-triggered and auto-triggered by the LDR sensor:
smart_apartment.ino#include <Servo.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> // ── Pin Definitions ──────────────────────────── #define PIN_BED 9 #define PIN_CURTAIN 10 #define PIN_TV 11 #define PIN_WARDROBE 12 #define BTN_BED 2 #define BTN_CURTAIN 3 #define BTN_TV 4 #define BTN_WARDROBE 5 #define LDR_PIN A0 #define BUZZER_PIN 7 // ── Servo angle settings ──────────────────────── // Bed: 10° = flat (down), 90° = folded (up) // Curtains: 30° = closed, 120° = open // TV: 90° = facing front, 55° = rotated sideways // Wardrobe: 10° = closed, 80° = open #define BED_DOWN 10 #define BED_UP 88 #define CURTAIN_CLOSED 30 #define CURTAIN_OPEN 120 #define TV_FRONT 90 #define TV_SIDE 55 #define WARDROBE_SHUT 10 #define WARDROBE_OPEN 80 #define LDR_THRESHOLD 600 // above = bright = open curtains Servo servoBed, servoCurtain, servoTV, servoWardrobe; LiquidCrystal_I2C lcd(0x27, 16, 2); // Feature state tracking bool bedUp = false; bool curtainOpen = false; bool tvRotated = false; bool wardrobeOpen = false; // Debounce tracking unsigned long lastPress[4] = {0,0,0,0}; #define DEBOUNCE_MS 600 // ── Helpers ───────────────────────────────────── void beep(int ms = 80) { digitalWrite(BUZZER_PIN, HIGH); delay(ms); digitalWrite(BUZZER_PIN, LOW); } void showStatus() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("BED:"); lcd.print(bedUp ? "UP " : "DWN"); lcd.print(" CRT:"); lcd.print(curtainOpen ? "OPN" : "CLS"); lcd.setCursor(0, 1); lcd.print("TV:"); lcd.print(tvRotated ? "ROT" : "FRT"); lcd.print(" WRD:"); lcd.print(wardrobeOpen ? "OPN" : "CLS"); } // ── Individual feature toggles ────────────────── void toggleBed() { bedUp = !bedUp; servoBed.write(bedUp ? BED_UP : BED_DOWN); Serial.println(bedUp ? "🛏 Bed FOLDED UP" : "🛏 Bed DOWN"); beep(); showStatus(); } void toggleCurtain() { curtainOpen = !curtainOpen; servoCurtain.write(curtainOpen ? CURTAIN_OPEN : CURTAIN_CLOSED); Serial.println(curtainOpen ? "🪟 Curtains OPEN" : "🪟 Curtains CLOSED"); beep(); showStatus(); } void toggleTV() { tvRotated = !tvRotated; servoTV.write(tvRotated ? TV_SIDE : TV_FRONT); Serial.println(tvRotated ? "📺 TV ROTATED" : "📺 TV FRONT"); beep(); showStatus(); } void toggleWardrobe() { wardrobeOpen = !wardrobeOpen; servoWardrobe.write(wardrobeOpen ? WARDROBE_OPEN : WARDROBE_SHUT); Serial.println(wardrobeOpen ? "🚪 Wardrobe OPEN" : "🚪 Wardrobe CLOSED"); beep(); showStatus(); } // ── Check one button with debounce ────────────── void checkButton(int pin, int idx, void(*action)()) { if (digitalRead(pin) == LOW && millis() - lastPress[idx] > DEBOUNCE_MS) { lastPress[idx] = millis(); action(); } } // ── LDR auto-curtain ──────────────────────────── void checkLightSensor() { int light = analogRead(LDR_PIN); // Open curtains when bright, close when dim if (light > LDR_THRESHOLD && !curtainOpen) { Serial.println("☀️ Sunrise — auto-opening curtains"); curtainOpen = true; servoCurtain.write(CURTAIN_OPEN); beep(50); delay(100); beep(50); showStatus(); } else if (light < (LDR_THRESHOLD - 100) && curtainOpen) { Serial.println("🌙 Getting dark — closing curtains"); curtainOpen = false; servoCurtain.write(CURTAIN_CLOSED); beep(50); showStatus(); } } // ── Setup ─────────────────────────────────────── void setup() { Serial.begin(9600); servoBed.attach(PIN_BED); servoCurtain.attach(PIN_CURTAIN); servoTV.attach(PIN_TV); servoWardrobe.attach(PIN_WARDROBE); // Start positions servoBed.write(BED_DOWN); servoCurtain.write(CURTAIN_CLOSED); servoTV.write(TV_FRONT); servoWardrobe.write(WARDROBE_SHUT); pinMode(BTN_BED, INPUT_PULLUP); pinMode(BTN_CURTAIN, INPUT_PULLUP); pinMode(BTN_TV, INPUT_PULLUP); pinMode(BTN_WARDROBE, INPUT_PULLUP); pinMode(BUZZER_PIN, OUTPUT); lcd.init(); lcd.backlight(); lcd.print("Smart Apartment!"); lcd.setCursor(0,1); lcd.print("All systems ready"); delay(1500); showStatus(); Serial.println("Smart Apartment Ready!"); Serial.println("Press buttons 2/3/4/5 to control features."); } // ── Main Loop ─────────────────────────────────── void loop() { checkButton(BTN_BED, 0, toggleBed); checkButton(BTN_CURTAIN, 1, toggleCurtain); checkButton(BTN_TV, 2, toggleTV); checkButton(BTN_WARDROBE, 3, toggleWardrobe); checkLightSensor(); delay(80); }
#define section (BED_UP, CURTAIN_OPEN etc.) are starting points. After assembly, open Serial Monitor (9600 baud) and test each feature. If the bed doesn't fold far enough, increase BED_UP from 88 to 95. If curtains open too wide, reduce CURTAIN_OPEN from 120 to 100. Tune each value until movement looks perfect!
analogRead(LDR_PIN) value in the loop — set LDR_THRESHOLD halfway between your dark and bright readings. E.g. dark=200, bright=800 → threshold=500.
Turn your working model into a beautiful miniature apartment:
- Flooring: Print a wood-grain pattern and glue to the floor
- Walls: Paint one accent wall a bold colour (navy, forest green, or warm terracotta)
- Mini furniture: Cut foam-board sofas, a coffee table, and rugs from coloured card
- Lighting: Add 3V LED fairy lights inside for ambient room lighting
- Control panel: Mount the 4 buttons on a mini panel outside the apartment — label each one with a printed sticker
- Plants: Add tiny fake plants cut from green sponge — details make the model come alive!
🛠️ Troubleshooting Guide
| 🔴 Problem | 🟡 Likely Cause | ✅ Fix |
|---|---|---|
| Arduino resets when servos move | All servos drawing too much current from Arduino | Connect servo VCC wires to external 5V 2A supply, share only GND with Arduino |
| Bed doesn't fold all the way up | BED_UP angle too low, or servo arm too short | Increase BED_UP from 88 to 95–100. Also check the arm length connecting servo to bed panel |
| Curtains don't open evenly | Thread lengths unequal | Adjust thread length so both curtain panels start equally distributed on the rod |
| TV servo jitters after stopping | Servo lib timer conflict on Mega with certain pins | Move TV servo to Pin 13 or any PWM pin marked ~ on the Mega board |
| LDR curtains trigger randomly | Threshold at the noise boundary | Add 100-unit hysteresis (open at 600, close at 500) — already in code. Increase gap if needed |
| LCD shows nothing | Wrong Mega I²C pins | On Mega, I²C is Pin 20 (SDA) and Pin 21 (SCL) — not A4/A5 like Uno! |
| Button triggers multiple times | DEBOUNCE_MS too short | Increase DEBOUNCE_MS from 600 to 800ms in the code |
🚀 Level Up Your Smart Apartment!
Once all four features work, these upgrades turn your model into a true smart home showcase:
Add ESP8266 Wi-Fi — control all features from a phone web page over your home network!
Add a voice recognition module — say "Open curtains" and the apartment obeys!
Add DHT11 sensor — tiny servo fan turns on automatically when temperature rises above threshold.
Add RFID module to the front door — only authorised cards can enter the apartment!
Add addressable LED strips (WS2812B) — scene-based lighting: Movie, Work, Sleep modes!
Log each feature's activation to SD card — display usage stats on the LCD at end of day.
❓ Frequently Asked Questions
The Mega has 54 digital I/O pins and 16 analog pins, compared to Uno's 14 digital and 6 analog. With 4 servos, 4 buttons, an LDR, a buzzer, and an LCD, we use 13+ pins — the Mega handles this comfortably with room to add more sensors for upgrades. The Mega also has more PWM pins for smooth servo control.
5mm foam board (available at any stationery shop) is ideal — it's lightweight, rigid, easy to cut with a craft knife, and takes paint and glue perfectly. For interior walls you can use 3mm foam board. Avoid regular cardboard for the main structure as it warps under the stress of servo motion.
SG90 and MG90S servos move to an exact degree when commanded — that's their core feature! The code sends exactly TV_FRONT (90°) or TV_SIDE (55°) and the servo moves there precisely every time. You can tune the exact angles in the code until the TV faces exactly the right direction.
Use a pulley system to give the servo more mechanical advantage — thread the line through a small spool at the top before attaching to the door. Alternatively, use a slightly stronger MG90S servo (metal gears, more torque). Make sure the door slides on a smooth rail with minimal friction — sand the rail lightly with fine sandpaper.
Absolutely! The Mega has plenty of spare pins. Add a new servo, new button, new boolean state variable, and new toggle function — then call checkButton() for it in the loop. The code pattern is identical for every new feature. A sliding sofa, a drop-down kitchen counter, or a rising bookshelf all work with the same approach.
Outstanding choice! It spans electronics, programming, mechanical design, and interior architecture. For the exhibition, add a cardboard "control panel" with labelled buttons in front of the apartment. Prepare a short demo sequence showing all features activating in order. Judges love seeing multiple integrated systems working together — it shows real system-level engineering thinking.

Comments
Post a Comment