In this video, I provide a complete tutorial on how to assemble your own stair lighting, featuring block diagram, code overview, testing and final layout. Code and schematic can be found on this page.

Table of Contents

Problem Statement

Design Choices

Microcontroller

Input Device

Output Device

State Machine

Code

Schematic

Assembly

Frequently Asked Questions

Problems Encountered

Potential Improvements

Conclusion

Success Stories

Problem Statement

The stairs at night were really dark. It was bad enough that we had to put lights next to it. However, these lights shined in your face and not the stairs. I wanted to light up the actual steps. I really thought the German video was cool, so I aimed for that animation as my goal.

Design Choices

Microcontroller

I chose the ATmega328P firstly because it was on the Arduino. It had the hardware SPI, a ShiftPWM library and good enough speed. If I was mass-producing these, I would probably have chosen a microcontroller with less pins.

Input Device

I had some choices when looking for “person detectors”. I could have used laser sensors, IR beam sensors like they use at the store, or the PIR motion detectors. I initially wanted to use the laser sensors because they show absolute presence vs just motion like the PIR sensors, but they were too finicky. The laser sensors had to be positioned just right on the photodiode, and I didn’t know where to buy the IR beams. The PIR motion detectors actually work very well.

Update 2014-11-09 Since the time of this post there has been a new product in the Adafruit store called a “laser break beam sensor”. If the delay on the motion detectors is completely intolerable then you could try one of these: http://www.adafruit.com/products/2122

Output Device

For output devices, it was clear that I wanted to use the strip LEDs vs the regular point LEDs. I saw some previous implementations like this one and gawked because they didn’t even light up the stairs, only the walls next to the stairs!

State Machine

Code

Code that runs on the microcontroller may be found on Github: https://github.com/androng/Shift-stairs

Here is a video to help you run the code:



Schematic

I laid out a board but never had it printed. It should be completely functional, but have a look before you print it, especially the minimum distance between traces etc.

EDIT 2014-10-28: I have finally tested the board and it almost works! This was one of my first PCBs and I messed up in my definition of the 2N7000. As a result, you have to solder in the transistors backwards in version 1.0 of the PCB. In version 1.1 this is fixed.

The small rectangle on the left side is a matching through-hole resistor for the photoresistor. I recommend populating the LED headers at the bottom with 2×40 male headers and using black female jumper wires to connect the LEDs. Or you could modify the board to make screw terminals.

Version 1.3: https://oshpark.com/shared_projects/2aD8JaBR

Changes:

1.3

Fixed “photoresistor always reads zero” problem

1.2

Added footprint for voltage regulator just in case someone fries the one on the Arduino Pro Mini

1.1

Fixed backwards transistor problem

Added more labels for power, motion detectors

Added labels for MOSFET source, gate and drain just in case you want to use a different MOSFET.





When you solder everything correctly, this should happen:



Assembly

You will need:

1x Arduino Pro Mini 5V, find on eBay

5m 3528 white LED strip, find on eBay

1x 12V 3A Power supply, find on eBay

PCB, $30 from OSH Park, see Schematic section for link

Enough wire for your stairs, you can also buy similar from Home Depot

2x PIR sensor or Laser sensor

PCB parts:

20x 2N7000 MOSFET or any other pin-compatible MOSFET. SOT-23 packages work well on the PCB too.

1x Single row female header

1x Double row male pin header

1x Single row male pin header

1x (Photoresistor and 10k resistor) (optional)

1x Switch (optional)

1x Screw terminal

2x 16-pin socket

2x 74HC595 Shift register

1x (LM7805 regulator and 0.1uF capacitors) (mandatory)

20x Female Jumper wires (one item comes with several wires)

Tools:

1x USB-to-UART

Soldering iron

Heatshrink and lighter – use the smallest size and cut into 3 pieces each

Wire stripper

Screwdriver

I recommend buying 2 or 3x everything in the “PCB parts” section in case you decide to start over.

Instructions

Assembly video and more detailed instructions coming in the future when I have time

Assemble Arduino Pro Mini–solder male headers below on the long sides and above on the short sides Set jumper on USB-to-UART to 5V Connect USB cable > USB-to-UART > Arduino Pro Mini and program it with Blink sketch Assemble PCB (refer to photo in PCB section) Solder female headers in the “Arduino Pro Mini” slot Solder LED+ and LED- with double row male headers Solder side pins like “motion” “switch” etc with male headers Solder in sockets for shift registers and insert the shift registers Insert Arduino Pro Mini with FTDI header in the middle of the PCB (optional) Solder in regulator and capacitors Assemble LEDs Cut a female jumper wire in half Put heatshrink on the half-jumpers Solder half-jumpers to a 2-conductor wire, then solder 2 conductor wire to LED. Connect your jumpers to the PCB male headers Repeat step 5 for however many stairs you have

Frequently Asked Questions

How do I adjust the number of steps? Only nine of the steps turn on.

Try editing this line first: https://github.com/androng/Shift-stairs/blob/master/Shift_Stairs.ino#L22

One of my lights doesn’t turn on/off or it flickers.

If it’s just one light then it’s a hardware problem. Try replacing the transistor that controls the flickering light or the light itself.

My lights stay on and never turn off.

Your transistors may be inserted backwards. Check the pinout on the datasheet.

Your transistors might be P-channel instead of N-channel. Check the datasheet.

One of my motion detectors does not trigger or has many false positives.

If the bottom stairs sensor does not work well, first I suggest swapping the top and bottom sensors to make sure you don’t have a bad sensor. Same behavior after swap means the wire to the bottom sensor needs to be thicker or the bottom of stairs need an environment change to accommodate the sensor, like a reflector on the other side of the step. Different behavior after swap means you have a bad sensor.

Problems Encountered

My choice of female headers as connectors for the LEDs was really bad. The headers are very secure, however all the wires are exposed and it is hard to place one in the middle. Other than that and the point-to-point soldering, I really did not have any problems.

Potential Improvements

Like stated in the video, I would have improved these things:

Use constant-current LED drivers

Add second override switch

Feature: first step always on at night

Route PCB with FTDI, ISP or Arduino socket on it.

Made duty cycle vary exponentially with brightness to cancel out the logarithmic perception of brightness. I almost did this, but the effect was not noticable enough for me to spend a lot of time on it. I left it in the code as a large array. (it should be placed in program memory)

Conclusion

I accomplished the objective of lighting up the stairs as well as adding some extra features like daylight detection. After a long time, I finally completed the documentation and edited together the film I captured so long ago! I feel accomplished.

Success Stories

People like you and me have succeeded in banishing the darkness! Publish a video to YouTube, link to it in the comments, and I will showcase it here. Include a link to this page in your video.

Boštjan Perme 2017-02-27

Joshua Mauldin 2016-10-16

troysbucket 2014-11-25:

msvetec 2015-10-04

SG 2015-12-01