Projects / Room occupied door sign

Room occupied door sign

Beginner1.7 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOmotion

    Wire the PIR

    VCC to 5V, GND to GND, OUT to D2.

  2. NANO

    Wire the lights

    Red through 220 ohms to D5, green through 220 ohms to D6, short legs to GND.

  3. NANOmotion

    Turn the PIR hold adjuster

    To the shortest setting.

  4. NANOmotion

    Upload the sketch

    The green light blinks for a minute while the PIR settles.

  5. NANO

    Wave a hand

    The red light comes on.

  6. NANO

    Keep still

    It stays red for five minutes, or ten seconds in test mode.

  7. NANO

    Wait

    It goes green.

In short

How do you build a room occupied door sign?

A PIR sensor above a door switches a red occupied light and a green free light, holding the red light for several minutes after the last movement so a person sitting still is not shown as absent. You need Arduino Nano, PIR Motion Sensor HC-SR501, LED 5 mm red, LED 5 mm green, Resistor 220 Ω × 2, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 7 steps and about 100 minutes.

Level
Beginner
Time
About 100 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
PIR VCCNano 5VPower at 5 V
PIR GNDNano GNDCommon ground
PIR OUTNano D2High when it sees movement
Red LED long leg220 ohm resistor to Nano D5Occupied light
Red LED short legNano GNDReturn
Green LED long leg220 ohm resistor to Nano D6Free light
Green LED short legNano GNDReturn

Code

A PIR sensor reacts to the change in heat radiation when a warm body moves, and sets its output high. Someone reading or sitting at a desk moves very little, so the sensor alone would say the room is empty after a few seconds. The program fixes this by remembering the time of the last movement and keeping the red light on for five minutes afterwards, and the green light shows only when nothing has moved for the whole of that time. The module needs about a minute to settle after power-up, so the green light blinks while the program waits. The module also has two small adjusters, one for its own hold time and one for sensitivity; turn the hold time to the shortest so the program has control and set the sensitivity to suit the room. Put it where it sees the seat and not the door, and away from heaters and sunshine. This is a courtesy sign. It is not a security device and not a safety device, because it can be fooled, and it must not be used to decide whether it is safe to enter anywhere. It records nothing about anyone.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const int PIR = 2;
const int RED = 5;
const int GREEN = 6;

const unsigned long HOLD_MS = 5UL * 60UL * 1000UL;   // stay red for 5 minutes after the last movement
// For a quick test, change HOLD_MS to 10000 (ten seconds), then change it back.

unsigned long lastMotion = 0;
bool everSeen = false;

void setup() {
  pinMode(PIR, INPUT);
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  // The sensor needs about a minute to settle: blink green while it does
  for (int i = 0; i < 60; i++) {
    digitalWrite(GREEN, i % 2);
    delay(1000);
  }
}

void loop() {
  if (digitalRead(PIR) == HIGH) {
    lastMotion = millis();
    everSeen = true;
  }
  bool occupied = everSeen && (millis() - lastMotion < HOLD_MS);
  digitalWrite(RED, occupied);
  digitalWrite(GREEN, !occupied);
  delay(100);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Power onGreen blinks for about a minute
Move in front of itRed on, green off
Sit still for a minuteStays red
Wait for the hold timeGreen on, red off
Move againRed again at once

If it does not work

Always red

Turn down the sensitivity and keep the sensor away from heaters.

Never red

Check PIR OUT on D2 and 5 V on the PIR.

Goes green while someone sits still

Make the hold time longer in the program.

LED never lights

Check the leg direction and the resistors.

Flickers at start

It is still settling, wait a minute.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the room occupied door sign?

Arduino Nano, PIR Motion Sensor HC-SR501, LED 5 mm red, LED 5 mm green, Resistor 220 Ω × 2, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the room occupied door sign take to build?

About 100 minutes for a beginner maker, in 7 steps.

How do I know the room occupied door sign works?

Power on: Green blinks for about a minute. Move in front of it: Red on, green off. Sit still for a minute: Stays red.

Always red: what should I check?

Turn down the sensitivity and keep the sensor away from heaters.

Never red: what should I check?

Check PIR OUT on D2 and 5 V on the PIR.

Goes green while someone sits still: what should I check?

Make the hold time longer in the program.

LED never lights: what should I check?

Check the leg direction and the resistors.