Projects / Staircase lights that follow you

Staircase lights that follow you

Intermediate3 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO13.5 mA

    Test the strip

    Light each group of 5 LEDs.

  2. NANOmotion

    Test the PIRs

    Print which one fires.

  3. NANO

    Light the steps in order

    Write the sweep.

  4. NANO

    Add direction

    Bottom first goes up, top first goes down.

  5. NANO

    Add the fade-out

    After 20 seconds.

  6. NANO13.6 mA

    Fit the strips

    One section under each step edge.

  7. NANOmotion

    Set the PIR aim

    Cover only the stairs.

In short

How do you build a staircase lights that follow you?

PIR sensors at the top and bottom of a staircase light the steps one by one in the direction you walk, then fade them out. You need Arduino Nano, PIR Motion Sensor HC-SR501 × 2, WS2812B addressable RGB LED strip (1 m, 60 LEDs), Electrolytic capacitor 1000 µF, Resistor 330 Ω, 5 V 3 A USB buck module (12/24 V to USB) and 12 V 2 A DC adapter. It takes 7 steps and about 180 minutes.

Level
Intermediate
Time
About 180 min
Parts
7

Parts list

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

Wiring

FromToWhy
12 V adapterBuck module inputPower (add a 2 A fuse in the 12 V lead)
Buck module 5 V outputLED strip 5V and Nano 5V5 V rail
1000 µF capacitorAcross the LED strip 5V and GNDAbsorbs switching spikes
Nano D6330 Ω resistor to LED strip DINData
Bottom PIR VCC, GND, OUTNano 5V, GND, D2Bottom sensor
Top PIR VCC, GND, OUTNano 5V, GND, D3Top sensor
All groundsJoinedCommon ground

Code

Each PIR looks at one end of the stairs. If the bottom sensor fires first the steps light upwards one after another, and if the top one fires first they light downwards, so the light travels ahead of you. After 20 seconds without movement the steps fade out. Each step has 5 LEDs of a WS2812B strip, with warm white at low brightness so night vision is kept and the current stays small, about half an amp for all 60 LEDs. The 1000 µF capacitor and 330 Ω data resistor protect the strip. Run the strip from a 5 V buck module off a 12 V adapter and fuse the 12 V lead. Hide wiring in channels so nobody trips, make sure the steps stay clearly visible with the lights off (marked edges), and never rely on these lights as the only safety light on a staircase. Test the PIR range and angle so a pet or a curtain does not trigger it. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

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).

// Staircase lights: direction from two PIRs, steps light in turn. Library: Adafruit NeoPixel. Board: Arduino Nano.
#include <Adafruit_NeoPixel.h>
const int STEPS = 12, PER_STEP = 5;                          // 12 steps, 5 LEDs under each (60 LEDs)
Adafruit_NeoPixel strip(STEPS * PER_STEP, 6, NEO_GRB + NEO_KHZ800);
const int PIR_BOTTOM = 2, PIR_TOP = 3;
const unsigned long HOLD_MS = 20000;
float level[STEPS];                                           // brightness of each step, 0 to 1
bool lit[STEPS];                                              // which steps should be on
unsigned long lastMotion = 0;

void setStep(int s, float b) {
  uint8_t v = (uint8_t)(b * 90);                              // warm white at low brightness
  for (int i = 0; i < PER_STEP; i++) strip.setPixelColor(s * PER_STEP + i, strip.Color(v, v * 0.6, v * 0.25));
}

void render() {
  for (int s = 0; s < STEPS; s++) {
    float target = lit[s] ? 1.0 : 0.0;
    if (level[s] < target) level[s] = min(target, level[s] + 0.08); else if (level[s] > target) level[s] = max(target, level[s] - 0.02);
    setStep(s, level[s]);
  }
  strip.show();
}

void sweep(bool upwards) {                                    // light steps one after another in the walking direction
  for (int i = 0; i < STEPS; i++) {
    lit[upwards ? i : STEPS - 1 - i] = true;
    for (int k = 0; k < 8; k++) { render(); delay(10); }
  }
}

void setup() {
  pinMode(PIR_BOTTOM, INPUT); pinMode(PIR_TOP, INPUT);
  strip.begin(); strip.setBrightness(255); strip.show();
}

void loop() {
  static bool active = false;
  bool b = digitalRead(PIR_BOTTOM), t = digitalRead(PIR_TOP);
  if (!active && (b || t)) {
    active = true; lastMotion = millis();
    sweep(b && !t ? true : (t && !b ? false : true));         // bottom first means going up, top first means going down
  }
  if (b || t) lastMotion = millis();
  if (active && millis() - lastMotion > HOLD_MS) {            // after 20 s of no motion, fade out step by step
    for (int s = 0; s < STEPS; s++) lit[s] = false;
    active = false;
  }
  render(); delay(10);
}

Test checklist

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

CheckExpected
Walk upSteps light from bottom to top ahead of you
Walk downSteps light from top to bottom
Stand stillLights stay on for 20 seconds, then fade
Pet at the foot of the stairsTriggers in the same way

If it does not work

Lights come on by themselves

Aim the PIRs away from windows and heaters.

Wrong direction

Swap the two PIR pins.

Strip flickers

Add the capacitor and the data resistor.

Last steps dim

Power the strip from both ends.

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

Ask Lark AI

Common questions

What parts do I need for the staircase lights that follow you?

Arduino Nano, PIR Motion Sensor HC-SR501 × 2, WS2812B addressable RGB LED strip (1 m, 60 LEDs), Electrolytic capacitor 1000 µF, Resistor 330 Ω, 5 V 3 A USB buck module (12/24 V to USB) and 12 V 2 A DC adapter.

How long does the staircase lights that follow you take to build?

About 180 minutes for a intermediate maker, in 7 steps.

How do I know the staircase lights that follow you works?

Walk up: Steps light from bottom to top ahead of you. Walk down: Steps light from top to bottom. Stand still: Lights stay on for 20 seconds, then fade.

Lights come on by themselves: what should I check?

Aim the PIRs away from windows and heaters.

Wrong direction: what should I check?

Swap the two PIR pins.

Strip flickers: what should I check?

Add the capacitor and the data resistor.

Last steps dim: what should I check?

Power the strip from both ends.