How to Assemble Stair Lights

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!

This person lit up the wall.

This person lit up the wall.

State Machine

Stairs State Machine 2 - New Page

 

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.

stairsPCB-1-1

 

PCB with connectors. I originally wanted to use the red connectors but I didn't realize they were too thick, so now I recommend the black connectors on the right side.

PCB with connectors. I originally wanted to use the red connectors but I didn’t realize they were too thick, so now I recommend the black connectors on the right side.

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

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

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

Screen Shot 2013-07-29 at 1.21.40 PM

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:

Screen Shot 2015-10-18 at 15.00.08

 

msvetec 2015-10-04

stairs lights demo

SG 2015-12-01

sample stairs lights

Advertisements

532 thoughts on “How to Assemble Stair Lights

  1. tcarnal

    Hi Andrew,

    thanks for designing and programming this awesome unit.
    Ive build two but had some issues with the PIR’s (due to the environment)

    Ive tried to solve this with other sensors GP2Y0A21YK0F
    the Work awesome but just up to 25 centimeters
    The problem lies in that the analog voltage out will range from 3V when an object is only 4″ (10 cm) away and 0.4V when the object is 32″ (80 cm) away.

    Unfortunately the Arduino has High on its input only when 3v is send to it.
    https://www.arduino.cc/en/Reference/Constants

    Im trying to read the code, and can read some of it, but i have no arduino experience and its and couldn’t quiet get it unfortunately.

    Could you spare me some thoughts?

    thx
    Thijs

    Reply
  2. Rainer Spuul

    Hey Andrew. What do you think, is it possible to use these laser switches to trigger the lights:
    http://www.ebay.co.uk/itm/Infrared-Laser-Alarm-Switch-Sound-Light-Alarm-Motion-Senser-Security-Diy-Kits-/131574426031?hash=item1ea27269af:g:kHsAAOSwNSxVJNks

    My stairs lights are working well but there are still issues where sometimes they wont trigger to movement and sometimes they trigger themself. So i’m in search of better triggering system.

    Thank you!

    Reply
    1. Andrew Post author

      Yes it is possible. If you know how to wire up the photoresistor such that it produces a high/low for the microcontroller and you run a wire to the other side of the stairs for the laser then it will work.
      My PIRs work fine if I angle them downward. No false triggers and they trigger every time.

      Reply
  3. Danny Graham

    Would it be possible for you to contact me through email….? I am getting the Brightness not declared in this scope error. I have read EVERY comment and your answers just to familiarize myself with ALL the issues identified with different experimenters and tried all the suggested remedies for this issue with no luck. From my conjecture, it seems the Arduino IDE is looking for a “brightnessSM.h” file for a library, but I have none in the unzipped collection of files. Is it possible that the “brightnessSM.ino” has to be pasted into the Stairs_Shift.ino and declared as an .ino?
    Thnx, Danny

    Reply
      1. Danny Graham

        Yes….I opened everything that was showing in your screenshot and it finished compiling without error. Having that brightness.ino open while attempting to compile wasn’t mention in the workflow. If it was…I must have missed it. Working with known to unknown approach, I had the suspicion that the compiler was looking for code from that .ino
        Thanx for the reply….now I just have to build the board.
        Stay tuned….I know about as much about Arduino as I do brain surgery, so this may turn out to be a painful experience.

  4. Danny Graham

    P.S. I’m sure it will be worth the pain…your project looks so cool it ain’t funny!! Additionally, it appears looking at the schematics that is can be tweaked to add quite a few other options as well.

    Reply
  5. Danny Graham

    Just to clarify….the board you have designed appears to accommodate up to 16 steps or channels. Is editing Line#22 to express the exact number of channels desired the only thing that needs to be done to utilize all 16?

    Thnx again, Danny

    Reply
    1. Danny Graham

      One last question for the time being until I get the board built and the Pro Mini ready to program……
      Is it possible to adjust + and – the time between when the first LED comes on/off and the successive ones after that? Looked thru the code and can’t discern where the timing is specified.
      Thnx, Danny

      Reply
      1. Andrew Post author

        Yes it’s possible, but not by adjusting one variable. I did not have adjustment in mind when I coded it. I’m working on a new version that allows it to be changed but it’s not ready yet.

      2. Danny Graham

        Mr. Andrew…Would it be possible to update the color image of the circuit board on this web page that illustrates the top and bottom traces in red and blue to Ver: 1.3?
        When I print the Eagle prints, the silkscreen obscures the traces that include the 7805 and caps that are on the project image site where the newer board file is downloadable. Or define point to point connections where the regulator and caps are incorporated into the existing color image or even a pencil line drawing of the addition to the 1.1 schematic?
        Sorry to pester…at work stoppage at this point until clarified.
        Thnx, Danny

  6. speed57

    Hi Andrew. I designed your PCB board accommodate my needs, but I have one problem though which is 1.3v you mentioned that voltage regulator and cap is mandatory. So I could not find it on your schematics. Can you able to share your 1.3 version schematics?
    That would be huge help.
    Thank you in advance.

    Reply
  7. Danny Graham

    I see. Well, is it worth building the project the way it is currently or will the “new & improved” be coming out soon enough to be worth waiting for instead?
    And…how did you learn your coding skills?

    Reply
    1. Andrew Post author

      The new version will come out in maybe a month and cost a lot more but it will be targeted toward people who don’t want to solder. I would just make it now and replace the code that adjusts the brightness. You’ll like it more.

      I learned from my high school teacher! =)

      Reply
  8. Danny Graham

    Well…I must say…it is quite a gift….I am just beginning to dabble in it. Would also like to be able to do PIC programming as well. However, for an old fart like me…the learning curve seem overwhelming.

    Reply
    1. Andrew Post author

      This is a nice and friendly beginner project to introduce you to the world of Arduino. Props for learning at “old fart” age. My parents dont learn anything new anymore.

      On Mon, Feb 26, 2018 at 6:34 PM, Speedy Signals wrote:

      >

      Reply
  9. Danny Graham

    Just curious…what other projects have you published? I’ve looked through all your archives and didn’t see anything on par with this stair light project.

    Reply
    1. Andrew Post author

      Did you check out the Electronic door lock project? It has a video too. To be honest I haven’t published much more because it takes weeks to make a video and I’m not sure what projects people want to see.

      On Mon, Feb 26, 2018 at 8:32 PM, Speedy Signals wrote:

      >

      Reply
    1. Andrew Post author

      It won’t happen any time soon. Try writing it yourself. That’s one purpose of this project. To help you understand basic timing code.

      On Thu, Mar 15, 2018 at 10:36 PM, Speedy Signals wrote:

      >

      Reply
  10. Amila

    I like your lighting system and i just want to build one too
    Can you please tel me what Arduino pro mini version should i buy and do you have any new PCB board design or i can use the V1.3
    Thanks in advance …

    Reply
    1. Andrew Post author

      Buy a 16MHz 5V Arduino pro mini. I have a newer PCB, v7.0, but it costs about $100 and it is fully assembled instead of the current v1.3 board that you have to buy and assemble yourself. The new PCB has no documentation yet and is not online, and it only works with 16 steps max. If you are interested, I can produce more documentation and ship you one for $100 and you can be an early access user. Or you can just order v1.3, which several people have used at this point.

      Reply
      1. Amila

        Thanks your feed back but i need 20 steps other wise it not nice with my staircase. Can I modify your PCB with extra 74HC595 Shift register and increase the steps count ? Is it possible?

      2. Andrew Post author

        It is possible but you will also need 4 more MOSFETs to go with the shift resisters. See the schematic for how to chain them.

  11. Amila

    One more i have 20 steps in diagram it show only 16 led . can i extend it easily to 20 steps
    is it same as PCB board design

    Reply
    1. Andrew Post author

      It’s not very easy to extend it to 20 steps. You’d have to edit the EAGLE file and fabricate a new PCB with OSH Park. The existing PCB will not work.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s