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

541 thoughts on “How to Assemble Stair Lights

  1. Brian

    Would you mind putting a more thorough description of this up? My expertise is more along the lines of programming, and looking at circuits is a little foreign to me (although I have been wanting to get more into electronics and ARM stuff). Can you provide a parts list that you used? Also, did you wire your solution in, or does it have a wall plug?

    This is great!

    Reply
    1. cosmocrazy Post author

      Sure. This is pretty much just a 74HC595 shift register project with bigger LEDs. The LEDs I used were “white strip LEDs” choosing the small 3528 LEDs, not the 5050, pretty similar to this: http://goo.gl/3jE8iO The wire is http://goo.gl/2ufUL2 which is the best deal at Radioshack considering you get 75×2 conductors = 150 ft of wire. The project box and motion detectors I also received from Radioshack. And of course there’s the minor components like the 2N7000 MOSFETs and screw terminals that I purchased from Tayda.

      Reply
  2. Pingback: DIY Strip Light Stair Lighting Design and Install » Stair Lighting

  3. Brian

    So is this a good parts list? I just want to make sure so I can buy it all at once. Been playing with my arduino for the last few weeks and I think I am ready!

    2x PIR Sense
    1x mini photocell
    1x 12V power supply
    1x arduino
    16(ish)x 2N7000
    Lots of wire
    Lots of led strip lighting
    I am not sure what the JP01-20 are… what part is that?
    I only see one resistor on there, and I dont see how many ohms… are there others?

    Am I missing anything?

    Reply
    1. cosmocrazy Post author

      I don’t see the shift registers on your list. The JP-01 and similar are the jumpers. If you are using my PCB layout above, then you can use 80-pin double row headers to populate them. Then you can solder these http://goo.gl/lUzURz to the lights and plug them right in.

      The photoresistor resistor value is not that important. I would suggest measuring the resistance of the photoresistor you plan to use at the time of day when you want the stairs to turn on and then matching that resistance value. This way, the ADC gives a reading of exactly half VCC at that time of day, or 512.

      The 12V power supply you will use is important. It needs to supply at least 2A or more if you have brighter LEDs, otherwise your LEDs will dim as more of them turn on. Make sure you buy the matching female barrel jack connector if you dont want to strip the wire on the power supply.

      Make sure that when you choose an LED strip, its a low-power (< 24W) strip. The 2N7000 MOSFETs cannot handle more than 200mA drain current each. So if you want bright lights you have to change the MOSFETs.

      You probably want to use an manual override switch or two at the top and bottom of the stairs too. I used one rocker switch that you can see in the video at 2:24.

      Reply
    1. Brian

      Shesh. I saw those… Don’t know how I forgot to put them on the list :-\

      Thanks for the advice. I will post pictures when I am done.

      Reply
  4. Michael

    Hy. Sorry for my englease. im from Rumania. can u send me a .hex or .cpp for Assemble Stair Lights,becouse i have some problems to upload in Arduino 1.5. and i wish to build this project. Thank you. Michael

    Reply
  5. j2host

    Excellent tutorial, very much what i was looking for, what would be the difference in pin-outs if i used an arduino uno, thank you so much.

    Reply
  6. Adri

    I like your project the most when it comes about lighting up stairs, you had a good idea in placing the led stripe in the middle of stair, like this the light it’s equal distributed on the sides..
    Therefore, I decided to implemented at home, but since I quite suck when it comes about electronics, I may have some questions (I hope not too stupid):
    does the 2N7000 is covering the needs of resistors for LEDs? Everywhere I saw, the LEDs are always with resistor, in your project.. no. Does the transistor do the job?

    thanks a lot!
    Adri

    Reply
  7. Aleksandar

    Great project! Thank you for sharing!
    I have a question about shift registers – on schematic you marked them as 74LS595N. and on PCB are 74HC595. I would like to use LED stripes with 5050 LEDs. So should I use 74LS595N or 74HC595?

    Reply
    1. Andrew Post author

      If I had to guess, the N in 74LS595N probably denotes the package type. You can use any kind of 74LS595 as long as you can make the connections.

      Reply
  8. AghilVinayak

    Hi,
    I have got with an error while uploading the .pde file,what should I do?

    ‘ShiftPWM’ was not declared in this scope
    Shift_Stairs.pde: In function ‘void setup()’:
    Shift_Stairs:61: error: ‘ShiftPWM’ was not declared in this scope
    brightnessSM.ino: In function ‘void brightnessSM()’:
    brightnessSM:29: error: ‘ShiftPWM’ was not declared in this scope
    brightnessSM:53: error: ‘ShiftPWM’ was not declared in this scope
    brightnessSM:133: error: ‘ShiftPWM’ was not declared in this scope
    brightnessSM.ino: In function ‘void transitionToOverrideSwitch()’:
    brightnessSM:146: error: ‘ShiftPWM’ was not declared in this scope

    Reply
    1. Andrew Post author

      You need to download the ShiftPWM library and add it to your sketch library folder. This is by default C:\Users\username\Documents\Arduino\libraries

      Reply
  9. sultan

    Very nice work. i have done it but i have faced some issues, when the sensor detects the movement it activates the lights and after 10 seconds it goes off, after that the lights never gets activated. What could be the problem. I am using and arduino uno would that have any effect.

    Reply
    1. Andrew Post author

      The problem could be in the motion detector. The PIR ones from Radioshack don’t give a high signal very frequently. It takes ~twenty seconds I believe. You can also try replacing the PIR sensor with a button and pull-up resistor and adding Serial.println() to state machine (brightnessSM). It could also be the analog sensor. If the room is too bright then the lights will not turn on.

      Reply
  10. sultan

    Thanks Andrew it worked with my Uno :). I have to switch my micro controller to Atmega8 what changes should be made for it to work. is t
    here any physical changes or just in the code.

    Reply
    1. Andrew

      You will have to try that yourself. The ATmega8 has half the program memory and RAM that the ATmega328 does for the same price, so I would use the 328. But it should work the same way as long as Arduino supports it and the pins are in the same place.

      Reply
      1. sultan

        i got this while trying to verify it.

        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp: In member function ‘void CShiftPWM::InitTimer1()’:
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:230: error: ‘TIMSK1’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp: In member function ‘void CShiftPWM::InitTimer2()’:
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:238: error: ‘TCCR2B’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:238: error: ‘WGM22’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:239: error: ‘TCCR2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:276: error: ‘OCR2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:279: error: ‘TIMSK2’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:279: error: ‘OCIE2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp: In member function ‘void CShiftPWM::PrintInterruptLoad()’:
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:293: error: ‘TIMSK1’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:303: error: ‘TIMSK2’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:303: error: ‘OCIE2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:323: error: ‘TIMSK1’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:326: error: ‘TIMSK2’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:326: error: ‘OCIE2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:344: error: ‘OCR2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:361: error: ‘TIMSK1’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:365: error: ‘OCR2A’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:369: error: ‘TIMSK2’ was not declared in this scope
        C:\Program Files (x86)\Arduino\libraries\ShiftPWM\CShiftPWM.cpp:369: error: ‘OCIE2A’ was not declared in this scope

      2. Andrew Post author

        If you look at the register names: TIMSK1, TCCR2B, WGM22, you will notice they are all for the ATmega48-328 series. In order to use ShiftPWM on the ATmega8, you would have to change all the register names the the equivalent if it exists.

  11. Hct

    Thank you so much for you tutorial.

    need to light up 11 stairs, should I change this # on line ‘const int NUMLEDs = 9;’
    with #11, and or do i need to change something else, sorry for noob Question

    also after verifying your code i got

    brightnessSM.ino: was not declared in this scope

    Shift_Stairs.ino In function ‘void loop()’;
    Shift_Stairs:110 error ‘brightnessSM’ was not declared in this
    scope

    if there’s any way you can help noob it would be appreciated, Thank you!

    #include
    #include
    //#include
    //#include “expoDutyCycles.h”

    //Data pin is MOSI (atmega168/328: pin 11. Mega: 51)
    //Clock pin is SCK (atmega168/328: pin 13. Mega: 52)
    const int ShiftPWM_latchPin=10;
    const bool ShiftPWM_invertOutputs = 0; // if invertOutputs is 1, outputs will be active low. Usefull for common anode RGB led’s.

    #include // include ShiftPWM.h after setting the pins!

    const int SWITCH_PIN = A0;
    const int PHOTORESISTOR_PIN = A2;
    const int MOTION_SENSOR_TOP_PIN = 2;
    const int MOTION_SENSOR_BOTTOM_PIN = 3;

    const unsigned char maxBrightness = 255;
    const unsigned char pwmFrequency = 75;
    const int numRegisters = 2;
    const int NUMLEDs = 9;
    const int MOTION_SENSOR_WARMUP_TIME = 10;
    const int ON_TIME = 10000; /* The duration between turn on and turn off. */
    const int LIGHT_THRESHOLD = 300; /* Anything below this sensor value will disable lights except override switch. */

    /* These are used to detect rising edges in the absence of interrupts.
    Using interrupts with ShiftPWM crashes the program. */
    unsigned char lastReadTopPin = LOW;
    unsigned char lastReadBotPin = LOW;

    volatile unsigned char topActivated = false;
    volatile unsigned char bottomActivated = false;
    unsigned long lastMotionTime = 0;

    const char BOTTOM_TO_TOP = 1;
    const char TOP_TO_BOTTOM = 2;
    /* For sake of the animation, stores the direction of propegation.
    Set when animation is active, cleared when animation is done. */
    char directionTriggered = 0;

    const unsigned long BRIGHTNESS_SM_PERIOD = 2000; /* in μs */
    unsigned long lastBrightnessSM = 0;

    /* LED 0 is on the top of stairs */
    unsigned char brightnesses[NUMLEDs] = {0};

    void setup() {
    pinMode(ShiftPWM_latchPin, OUTPUT);
    SPI.setBitOrder(LSBFIRST);
    // SPI_CLOCK_DIV2 is only a tiny bit faster in sending out the last byte.
    // SPI transfer and calculations overlap for the other bytes.
    SPI.setClockDivider(SPI_CLOCK_DIV4);
    SPI.begin();

    Serial.begin(9600);

    /* Turn on pullup resistor for switch */
    digitalWrite(SWITCH_PIN, HIGH);

    ShiftPWM.SetAmountOfRegisters(numRegisters);
    ShiftPWM.Start(pwmFrequency,maxBrightness);
    // Print information about the interrupt frequency, duration and load on your program
    ShiftPWM.SetAll(0);
    ShiftPWM.PrintInterruptLoad();
    // Fade in all outputs
    for(int j=0;j=0;j–){
    ShiftPWM.SetAll(j);
    delay(3);
    }
    }
    void loop()
    {
    /* Detect rising edge with polling. Interrupts crash the program. */
    unsigned char pinRead = digitalRead(MOTION_SENSOR_TOP_PIN);
    if(pinRead == HIGH && lastReadTopPin == LOW){
    topActivated = true;
    }
    lastReadTopPin = pinRead;
    /* Detect rising edge with polling. Interrupts crash the program. */
    pinRead = digitalRead(MOTION_SENSOR_BOTTOM_PIN);
    if(pinRead == HIGH && lastReadBotPin == LOW){
    bottomActivated = true;
    }
    lastReadBotPin = pinRead;

    /* Resets flags */
    if(topActivated){
    if(directionTriggered == 0){
    directionTriggered = TOP_TO_BOTTOM;
    }
    lastMotionTime = millis();
    topActivated = false;
    }
    if(bottomActivated){
    if(directionTriggered == 0){
    directionTriggered = BOTTOM_TO_TOP;
    }
    lastMotionTime = millis();
    bottomActivated = false;
    }

    /* State machine */
    if(micros() – lastBrightnessSM > BRIGHTNESS_SM_PERIOD){
    brightnessSM();
    lastBrightnessSM = micros();
    }
    }
    /**
    Returns true if switch is in “1” position.
    */
    boolean switchPressed(){
    return !digitalRead(SWITCH_PIN);
    }

    Reply
    1. Andrew Post author

      Yes, you should just be able to change NUMLEDs. The error brightnessSM.ino: was not declared in this scope is probably from running an old version of Arduino because it doesn’t recognize ino files. I recommend at least Arduino 1.0.

      Reply
  12. suliman

    hello,
    I searched for the Arduino 1.0 but I could not find it.
    with the Arduino 1.0.5 it does not work and it gives the error mentioned above.
    can you help by converting this code to a hex file and share?
    Regards

    Reply
  13. Hct

    Thank you Andrew for your quick reply, I’m also running Arduino 1.0.5, reading suliman’s post indicated help with Hex file, and yes to click “download ZIP” while at GitHub to download all the files? . Reading online, found an enhanced arduino release download, says it works with hex file, try that, or is there another solution.

    Reply
  14. Andre

    Hey!
    i really love your project and i will build this in my house as soon as it is built ; ) There are some things i do not understand yet and would like to ask you for you help.
    First i would like to know why the 74HC595 are called in 74ls595n in your schematic? As far as i understood the 74hc595 are used and enough? Furthermore i am confused by the schematic: Is the shift register mirrored (the connections on the right are supposed to be on the left and vice versa)? I only found datasheets with the q rows on the left side.
    My last and most importand question: Is there also a schematic available which shows all connections completely? I did not fully understand where the sck, rck and so on connections go to.
    My assumption would be:
    11 / 11 / SCK are connected (daisy chaining)
    12 / 12 / RCK are connected (daisy chaining)

    Are there more pins to be connected and where do the arduino connections go?
    thank you very much!

    Reply
    1. Andrew Post author

      I’m glad you liked it. Yes, the 74HC595 and 74LS595 should be the same. I believe they are just from different companies. Double check the pinouts to make sure they are the same.

      The schematic is good the way it is, trust me. If two nets are connected, they have the same name. For example, LEDCTRL7 has two instances and they are right next to each other. Similarly, SCK and SS are directly connected on both registers. “Daisy chain” means cascade in series, not just connect multiple wires to the same point. The daisy chain is shown with a wire from pin 9 of one register to pin 14 of the other.

      The shift registers are not mirrored. You are correct in that the Q outputs are supposed to be on the left. The datasheet shows the physical pinout. The schematic however can show symbols however it wants. Notice how there are ten pins on the right and eight on the left. The schematic symbol does not have to match physical pinout.

      Reply
  15. John

    I’m an absolute beginner in regards to putting a project like this together and the extent of my small electronics skills goes only as far as soldering mod kits to Playstations. I need some help with the full parts list that I’ve kind of put together. Currently I have:

    > (2x) PIR Sensors
    > 12V power supply
    > (x13) LED light strips
    > Arduino UNO
    > (x13) 2N7000 transistors
    > (x5) 74HC595 shift register

    But I know there’s a few things I need to complete this puzzle. What are these called and where can I buy them?

    > The circuit board that you used? (I got a breadboard and it’s great for little projects but I don’t think it will work for this.)
    > Those cradle things that hold the shift registers to the circuit board?
    > A bigger shift register? (But it looks like you’re using an Arduino mini so the UNO should handle that I’m guessing?)
    > The wire you used for connecting the component together on the circuit board?
    > Screw terminals (I will be getting 3.5mm DG350 from Tayda)
    > Speaker wire (I will be getting what you recommended from Radio Shack in a comment reply)
    > Something else I’m missing?

    Thank you so much for your help and your ingenious creation!

    Reply
    1. Andrew Post author

      I’m glad I was able to motivate you! That is my aim of the video I created.

      • The “cradle things” are called IC sockets. I suggest the 16-pin IC socket from Tayda, A-003.
      • You make larger shift registers by chaining small registers together. In my case, it is two eight-bit registers as one sixteen-bit register. Note on the schematic the wire that connects the two registers.
      • The circuit board you saw in the video was painstakingly soldered by my own hand over a period of several weeks. I do not recommend this method. You don’t learn much, it takes way too much time to perfectly cut the wires, and you only get one board. Instead, you should download the board files for the PCB I made and submit them to OSH Park or similar to make for you. Or even make your own, smaller board.
      • Yes, buy the speaker wire from Radioshack. It’s cheap and already in two-conductor form.
      • On my PCB I used 5mm screw terminals. DG350 is 3.5mm pitch. Careful about this.
      • You have a lot of choices for connecting the wires to the board. You can use screw terminals if you like taking up a ton of space. You can solder the lights directly to the board. The method I recommend is buying these BEC connectors for the lights and mating them with double-row male headers (where it says LED- and LED+) on my PCB.
      Reply
      1. John

        Ok I updated my inventory and got a few circuit boards made and the extra parts but I have questions regarding the board and the PIR motion sensor.

        On the PIR:
        > When I straight-up wired one of the PIRs to a light on a breadboard they seem to not work. The LED strip is dim compared to if I directly connect it to the power source and the PIR doesn’t even seem to detect motion. Why is this? Does it have to go through an Arduino for it to work?

        > The PIR has three connectors, is there something I can use to easily connect the wires to the sensor without soldering them directly on?

        On the circuit board (this thing is super cool):
        I’ve been able to figure out most of the layout but on the left side there’s a few holes that I can’t figure out.
        > The bottom left is the power: do I just solder the wires directly in, or is there a component that I need like the outline on the board suggests?

        > What’s the long rectangular box on just above the power for?

        > Above that, what photo res thing do I need?

        > And then there’s the switch? I don’t remember there being a switch. Is this something else I need to buy?

        > The next up are the two motion sensors. However, as with the long rectangular thing, the photores, and the switch, the board doesn’t signify which hole is the positive and which is the negative. Could you clarify those a little bit?

        > My Arduino Mini doesn’t have all those holes that the PCB has on it. how will this thing be connected to the board? (looking at it closely I can see 7? lines coming from those rows of holes; is that all I need to do to connect them?)

        Thank you so much for all your help. It’s getting so close to being finished and I really excited to see this thing work!

        John

  16. John

    I found out that the PIR I have is for 3V to 5V so I believe that’s the reason each led strip has transistors on it.

    I also realized that I purchased the wrong Arduino. The 24-pin one that you have for the PCB is the Arduino Mini 05. One issue I have with it is I don’t know where to plug in the USB cord to program it!

    I’m still having trouble identifying what goes in the other places for leads on the left side of the board, however (questions in my previous post).

    Reply
    1. Andrew Post author

      > When I straight-up wired one of the PIRs to a light on a breadboard they seem to not work. The LED strip is dim compared to if I directly connect it to the power source and the PIR doesn’t even seem to detect motion. Why is this? Does it have to go through an Arduino for it to work?

      You will need a buffer circuit that outputs 12V. This is what the Arduino and MOSFETs are for.

      > The PIR has three connectors, is there something I can use to easily connect the wires to the sensor without soldering them directly on?

      I used female-to-female jumper wires.

      On the circuit board (this thing is super cool):
      I’ve been able to figure out most of the layout but on the left side there’s a few holes that I can’t figure out.
      > The bottom left is the power: do I just solder the wires directly in, or is there a component that I need like the outline on the board suggests?

      I put in the footprint for 2-pin 5mm pitch screw terminals. Of course you can solder in wires too, but I recommend having some kind of removable plug.

      > What’s the long rectangular box on just above the power for?

      That is the place for the through-hole matching resistor that pairs with the photoresistor. Measure the resistance of the photoresistor you want to signify the border between “day” and “night”. Then use that resistor in that rectangle. Then in Arduino, simply change LIGHT_THRESHOLD to 512.

      > Above that, what photo res thing do I need?

      Any CdS photoresistor will do. Like this one: http://www.taydaelectronics.com/photo-conductive-cell-resistor-ldr-650nm-radial-ke-10720.html

      > And then there’s the switch? I don’t remember there being a switch. Is this something else I need to buy?

      The switch is optional–the program uses it to keep the stairs on permanently while the switch is thrown. Sometimes it is nice to have one at the bottom of the stairs for when you are unloading groceries and the stairs are the first thing you see in the house.

      > The next up are the two motion sensors. However, as with the long rectangular thing, the photores, and the switch, the board doesn’t signify which hole is the positive and which is the negative. Could you clarify those a little bit?

      My mistake. I clicked on the red trace in the Eagle BRD file and found the signals to be GND, signal, VCC from left to right.

      > My Arduino Mini doesn’t have all those holes that the PCB has on it. how will this thing be connected to the board? (looking at it closely I can see 7? lines coming from those rows of holes; is that all I need to do to connect them?)

      Use these ( http://www.taydaelectronics.com/40-pin-2-54-mm-single-row-female-pin-header.html ) to populate the two long rows of holes, then use this http://www.taydaelectronics.com/40-pin-2-54-mm-single-row-pin-header-strip.html to populate the six holes on the Arduino Mini or Pro Mini, then use this http://www.dfrobot.com/index.php?route=product/product&product_id=581 to program the Arduino.

      Reply
  17. John

    OK. I got most of the soldering done, and I’m still waiting on a few items in the mail. But!

    Is there an easy way to test that my soldering connections are good? I made a lot of soldering today, and if I manage to get the code on the mini and get that soldered in, and see that things aren’t working, how do I troubleshoot it? How will I know that it’s a soldering issue or that it’s a code issue?

    When I upload the code (and I don’t know how to connect the Tx and Rx and the other 4 ports), how to I know that it sucessfully made it to the mini?

    And since I’m waiting for the switch and the photoresistor, is there a way that for the time being I could bypass those items on the PCB? You originally didn’t have those things and wanted to add them in a perfect world but I’m really stressed for time and I just need something working so while I have the parts here all ready in and the others are nice afterthoughts, can I get it to work without the switch or the photo resistor or that other thing that goes just above the power?

    John

    Reply
    1. Andrew Post author

      Solder connections are almost never an issue on through-hole boards if you covered the whole pad. It will likely be something else. You can use your multimeter and an oscilloscope/logic analyzer if you have one to determine signal integrity.

      When you upload the code, you can tell it is uploading when the TX/RX lights on the programmer blink rapidly and it says “Done uploading” on the IDE. The LED on the Arduino will also blink every time you reset it. (the reset happens automatically upon programming)

      Both the switch and photoresistor are optional and never have to be added. But you need that resistor in the rectangle. The code should work unmodified with these elements missing.

      On Thu, Oct 9, 2014 at 6:52 PM, Speedy Signals wrote:

      >

      Reply
  18. John

    I downloaded your code and when I try to open the shift_stairs.pde it wants to create a new folder and toss it in there. If I do and verify some of your code isn’t declared (for example the ShiftPWM wasn’t declared) when I know it is.

    Reply
    1. Andrew Post author

      Yes, you need to download the whole folder of code and open Shift_stairs.pde while in that folder like it implies. If you do not, it will try and create the folder for you. You also have to have the ShiftPWM library in the correct directory: /libraries/ShiftPWM You can find in your Arduino preferences.

      On Fri, Oct 10, 2014 at 7:07 AM, Speedy Signals wrote:

      >

      Reply
  19. John

    OK. I downloaded the ShiftPWM library. I renamed the Shift-stairs master folder to Shift_Stairs and when I clicked on the Shift_Stairs.pde file it opened without a problem. I then went to sketch > import library and added the shiftPWM zip file. When I compiled it, here’s the error I got:

    This report would have more information with
    “Show verbose output during compilation”
    enabled in File > Preferences.
    Arduino: 1.0.6 (Windows 7), Board: “Arduino Uno”
    Shift_Stairs.cpp.o: In function `ShiftPWM_handleInterrupt’:
    C:\Users\Mearth\Desktop\Shift_Stairs\libraries\ShiftPWM/ShiftPWM.h:154: undefined reference to `ShiftPWM_balanceLoad’

    Secondly, I’m still having confusion about the resistor for the photoresistor (the rectangle next to the power. You said it accompanies the photoresistor, so I bought some LDR 5mm ones
    http://www.taydaelectronics.com/photo-conductive-cell-resistor-ldr-650nm-radial-ke-10720.html
    but they only came with the little photoresistors. So these guys (If I choose to use them later) I’ll solder into the “Photo Res” on the board, but I’m still unclear what I need for that rectangle?

    I feel so close to getting it!

    Reply
  20. John

    My apologies. I downloaded your zip and had to rename the shit-stairs master folder to Shift_Stairs for the pde to open without that error.

    I’m assuming that this verifying error is because I don’t have the PWM library installed correctly. I set the sketchbook location to Shift_Stairs (This makes a “libraries” folder inside the Shift_Stairs folder). Then I go to, Sketch > import library and navigate to the zip and click open. In the libraries folder there’s now a ShiftPWM folder. (If I go back to the sketch > import library at the bottom there’s a “contributed ShiftPWM” so I’m guessing it’s added?)

    Clicking Verify I get this:

    Shift_Stairs.cpp.o: In function `ShiftPWM_handleInterrupt’:
    C:\Users\John\Desktop\Shift_Stairs\libraries\ShiftPWM/ShiftPWM.h:154: undefined reference to `ShiftPWM_balanceLoad’

    Reply
    1. Andrew Post author

      So first, I recommend not putting your libraries folder in your project folder. This works for one project but then quickly becomes messy if you have multiple projects. I would separate the libraries and project folders.

      Yes, after following your steps, I was able to reproduce your error. This error is actually not your fault. We are using two different versions of the ShiftPWM library and in the newer one you downloaded, there is additional functionality for load balancing. I don’t really need this and I don’t know how to fix it, so instead, I added my old version of the ShiftPWM library to the repository.

      I also renamed the Shift_stairs file so there is a little less confusion. You still have to remove the dash and replace with an underscore “Shift-stairs-master” > “Shift_stairs” but that should be easy.

      On Sat, Oct 11, 2014 at 8:17 AM, Speedy Signals wrote:

      >

      Reply
  21. John

    That did it! I got it to compile successfully.

    I have an arduino mini05 with a FTDI and I’m getting a sync error. Even trying to upload the simplest code the Rx on the FTDI flashes three times and the I get the sync error. I’ve put hours into troubleshooting it, talking on forums, trial and error (and error and error!)
    Here’s my setup (except no capacitor, resistor, or LED)

    From the FTDI to the mini I’ve go this set up:
    GND to GND
    5V to 5V
    Reset to R
    Rx to Tx
    Tx to Rx

    To troubleshoot, some folks say to hit the reset button just before the upload. Doesn’t work.
    Some said to unplug the 0 pin on the mini (with is the Tx) and I’ve tried that, but if the Rx on the FTDSI sends data to the Tx on the mini and I unplug the 0 pin, then they aren’t talking to each other!
    Some said the reboot my PC, tried that.
    Some said to get the right COM port and the right board so I looked in the device manager when plugged in (drivers are up to date) and have the right COM and the board selected is Arduino Mini w/ ATmega328.
    I thought I’d ask you if you have any hail-mary ideas being a genius.

    Alternatively, I have an UNO, and I can upload to it with relative ease. Someone on this blog asked if you could use an UNO and the PCB and you said yes if the pins were lined up. I checked the PCB schematics and counted 10 placed on the PCB I’ll have to solder some jumpers and connect it to the UNO. Is that the right number of contact points to the PCB?

    I also have a question about the resistor. I heard that the direction you put the resistor on is important. When I look at my resistors there’s a band on either side, so which way should I aim it when I solder it onto the board?

    Reply
    1. Andrew Post author

      Huh. I never actually used the “Arduino mini” before. I have only ever used the Arduino Pro mini, which has the same footprint but doesn’t require all this breadboard wiring. On the Pro mini you can directly connect the USB adapter and the Arduino. I recommend buying that next time.

      I don’t recommend soldering from the Uno board. That’s for people who don’t have the standalone USB adapter. Let’s just fix the breadboard setup.

      That capacitor is actually necessary–it is a coupling capacitor, not a decoupling capacitor. You cannot skip it.

      I would also recommend adding the LED to pin 13 because the LED blinks when the microcontroller resets. This indicates that your reset line is working. Try it on the Arduino Uno. Press the reset button. And then upload something. If you were to add the LED to your Arduino Mini setup right now, you would notice no such blink because it’s not being reset. Add the capacitor and you should see a blink.

      Resistors are not polarized. Direction does not matter.

      On Sun, Oct 12, 2014 at 11:39 AM, Speedy Signals wrote:

      >

      Reply
  22. John

    I got a new mini pro and it looks like the code uploaded successfully. Everything is soldered in. I then got a few mini led strips (scraps) hooked up to for testing and attached it to the board. When I finally plugged it in the lights came on… and they stayed on.

    I haven’t changed the code at all, so maybe I have to comment a few things out since I have no switch or photores hooked up (but I did put in that 10k resistor)? Also, when I unplug the motion sensors from the PCB the LEDs still stay on (if that helps at all). Any ideas?

    Also the motion sensors have little dials for sensitivity and whatnot, should those be set at a specific place?

    I also only have 13 steps. Is there a place in the code I need to change for the right stair number?

    John

    Reply
    1. Andrew Post author

      The motion sensor dials should not matter. That’s just a timeout and the interrupts are level change detection.

      The number of stairs is the NUMLEDs variable.

      The LEDs staying on could be for a number of reasons and it is hard to diagnose without probing your board. Check that the ICs and transistors are inserted in the correct direction.

      I am pretty sure you are the first person besides myself to print my PCB. This is cool! I have not actually assembled and tested it myself yet. You will be the reason for me to try within the next week. I will let you know whether I succeed or fail with my design.

      On Wed, Oct 22, 2014 at 7:08 PM, Speedy Signals wrote:

      >

      Reply
    2. Andre

      Hey John! Where did you fabricate the pcb? I also considered making one but about 60 Euro for one pcb is way to expensive …

      Reply
    3. Andrew Post author

      I investigated the “LEDs staying on” problem by assembling the PCB and I achieved the same results. The good news is that it’s not your fault! I messed up the pinout of the 2N7000 and got it backwards, so the bad news is that you have to throw out the PCB you already soldered. The second good news is that this is not a fatal error meaning you can still use the PCBs you’ve already printed, just make sure to solder the transistors backwards.

      Reply
      1. Andre

        hey andrew. Would you mind making an update for the eagle files? I cannot change this in eagle and it would be awesome if it worked right out of the pcb factory …

      2. Andrew Post author

        It is currently fully functional, you simply have to solder the transistors backwards. It will take me some time to re-route the whole board so I don’t recommend waiting.

      3. Andre

        sorry for the stupid question: With backwards you mean soldering on the other side of the pcb? So that the s (1) and d (3) legs are reversed? (1 would be on the side of 3 and vice versa)

      4. Andrew Post author

        Yes, reverse pins 1 and 3. But don’t solder them to the other side of the board, just rotate the MOSFET 180 on it’s long axis.

        On Wed, Oct 29, 2014 at 12:14 AM, Speedy Signals wrote:

        >

  23. Andre

    Maybe anyone in Germany is also interested in making the pcbs? We could order a small batch of 5 to 7 pcs which would make them much cheaper …

    Reply
  24. Andre

    I am sorry i have to »spam« this thread again ; ) What kind of pro mini do you use? the 8 mhz 3.3 v or the 5 v at 16 mhz?

    Reply
    1. Andrew Post author

      You should buy the 5V Arduino because it means less wasted voltage on the voltage regulator and higher gate voltage on the MOSFETs. It’s also faster.

      Reply
  25. troysbucket

    Well crap, I have the transistor in backwards! I don’t have enough for a second board, so I’ll have to take these off and flip them for the time being.

    Here’s a couple pics of what I got. Additionally, those guys that I soldered in that go to the lights, along with the connectors you linked from ebay don’t work together. The plastic around the connectors is too thick to put on each of those little guys; they’re too close!


    Reply
    1. Andrew Post author

      You are right–I acknowledged that in the post update. I did not test those red connectors before recommending them and this is my fault. I will not recommend things before testing them next time.

      Reply
    2. Andre

      Andrew, Do you know, why the item description (motion and so on) is doubled? I also saw this on the fabrication preview.
      And i just wanted to say thank you again for your tireless efforts regarding our questions : )

      Reply
  26. troysbucket

    Don’t worry about it. I have another couple PCBs somewhere and it seems that I have enough supply to make another one except for the transistors (which I can salvage if it comes to that).

    Any ideas on how to take out the transistors? I spend about half an hour and all I can do is clean off the ends but I can’t get them out. I heat one up and the other two hold fast so I can’t push them through. I have some unsolder wire mesh that I could use.

    Reply
  27. Andrew Post author

    It was personally incredibly painful just removing one at a time. I had to use my widest soldering iron tip to heat all three legs at once while constantly applying force with tweezers to remove the TO-92 transistor. If there is enough leg room then I would suggest using flush cutters to simply cut them from the top–or use another TO-92 N-channel MOSFET with the same pinout and drain current rating.

    Reply
  28. troysbucket

    I got the transistors clipped and everything soldered correctly. It’s a beautiful soldering job, but now it seems that I get that sync error with my arduino mini Pro. I’m extremely frustrated with their software disappointed with their components.

    I’ll either get the “Serial port ‘COM6’ already in use, or the familiar sync error with two of the mini pros I have. Everything else is ready to go.

    Reply
    1. Andrew Post author

      From your photo above, the Pro mini is soldered in backwards. The mark on the PCB that says “FTDI” was supposed to indicate that the side with the TX, RX, VCC, GND (FTDI programming header) was near the middle of the board, not the edge. I did this because I presumed people would want the PCB in an enclosure, and having the programming header on the edge of the board instead of the middle would be annoying if the walls of your enclosure were too close to the edge of the board.

      I also recommend not soldering the Pro Mini directly to the board, but rather soldering the Pro Mini to the male headers and then soldering female headers to the PCB, then mating them like in the second photo in the Schematic section above.

      Reply
  29. troysbucket

    I pulled out my third, and last mini pro and the lights flashed and it uploaded just fine (I think). I’m using 750 degrees to solder the points to the board, could I have fried the mini pro? what temperature should I be using?

    Reply
  30. troysbucket

    Where did you buy your black connectors for the leds that you plug in (the one on the right in your picture)? It looks like they might be thin enough to put side-by-side.

    For the female headers what did you buy. I purchased these:
    http://www.taydaelectronics.com/40-pin-2-54-mm-single-row-female-pin-header.html
    will they work? (just want to know before I ruin my final board.)

    When you solder the male headers to the mini pro, what temp was your soldering iron? I’m worried about soldering the headers to this last mini pro and want to make sure I get them on without possibly burning out the board. I’ve looked online for a “max temp” to solder the mini pro but there’s no place that lists a burnout temperature.

    Reply
    1. Andrew Post author

      Could you please take a screenshot of the item in question? I do not understand the question.

      On Thu, Oct 30, 2014 at 5:49 AM, Speedy Signals wrote:

      >

      Reply
  31. troysbucket

    I bumped down the temp to 650 and soldered the male headers to the mini pro #3 (550F didn’t seem to be hot enough).

    Then I took my second PCB (the one I soldered perfectly) and ripped out the mini pro I soldered on it. (The mini pro #2 was destroyed.) Then I took my pointy end of the iron and pushed all the remaining scraps of male headers out of the holes in the PCB. I cleaned the holes up the best I could and clipped and soldered the female headers linked below.

    http://www.taydaelectronics.com/40-pin-2-54-mm-single-row-female-pin-header.html

    I fitted the mini pro #3 (the one that looks like it uploaded correctly) to the new female headers and tried to attach those clips (the red ones) to the PCB. However I took off the red clips so it was just the wires. When I plugged it in, they all lit up and then most went dim, although some stayed bright. I plugged in several different motion sensors and none of them were responsive. I then focused on trying to get the lights all off and the PCB made a shorting sound and smoke.

    I unplugged it and removed all the exposed wires and then inspected the PCB. I couldn’t find any black scorch marks so I tried again, only this time with the red ends still attached. I put it on every other one so I got about 7 on there. I plugged it in and some led strips just stayed on while others were fading in and out when I pressed the reset button.

    1. What could be the issue for some of the lights staying on?

    2. Where can I get those jumpers like you have in this picture (the green and yellow ones on the right)? https://speedysignals.files.wordpress.com/2013/08/2014-10-28-00-10-47-21.jpg

    Reply
    1. Andrew Post author

      The issue of the LEDs staying on is almost certainly a transistor problem. The solder joints might not be completely clean or transistors may be backwards.

      The jumper wires can be found here: http://www.ebay.com/itm/Female-Color-Ribbon-Flat-Cable-Jumper-Dupont-40-Wire-20cm-1P-1P-2-54mm-DE4067-/370946400953?pt=LH_DefaultDomain_0&hash=item565e20e2b9 You cut the wires in half and color code + and – on the LEDs

      For reference, here is the intended function of the device: http://youtu.be/Lc4w2SDPnmE

      Reply
  32. denver

    Just started getting involved in Arduino boards and loving it, great project but Im stumbling over getting the project into the Arduino program. Ive tried so many different ways and am now getting confused. Ive deleted everything and am starting again. Ive added the zip file to the library so I can now see it in the library but where do I go from here, Im using a Mac so don’t know if its any different.

    Reply
  33. troysbucket

    The transistors aren’t backwards (er, the way as illustrated on the PCB). I made sure that they were soldered 180 degrees on axis so the 1 and 3 pins are opposite. So what I did was flip the PCB over and reheat (at 650 degrees) each of the soldering points and try to add a little more solder. It didn’t seem to work. I’m not sure what to do now (aside from trying to solder another PCB, but I’ll try to heat these up again and see if I can’t get a proper solder.

    1. On your schematic

    am I right to assume that the male headers (looks like JP5 through JP20) coincide with the transistors (Q1 through Q16) where JP5 = Q1, JP6 = Q2 and so on?

    2. For the existing transistors, do you think I fried them (when I soldered them on at 750 deg. F) or that there might be any way to repair them or the connectors?

    I bought a bunch of each of these things:
    http://www.taydaelectronics.com/catalogsearch/result/?q=jumper
    so I think they’ll be good to use on the male headers when they get here.

    Reply
    1. Andrew Post author

      1. That is correct. You linked to the layout but it is much easier to deduce such connections from the schematic. https://speedysignals.files.wordpress.com/2013/07/stairs.png This makes it much more clear that Q1-Q16 are connected to JP5-JP20.

      2. Modern electronics are very generous and should continue to work even after being exposed to very high temperatures. If you really wish to salvage the transistors there are other troubleshooting methods that you can try. Try troubleshooting the MOSFETs alone. As in remove the shift registers from their sockets and wire 5V/0V to pins 1-7 of the shift register socket, which connect directly to the gate of the MOSFETs. The LEDs should turn on when you apply 5V and off when you apply 0V. If they don’t then you know its a MOSFET problem.

      Reply
  34. denver

    Thanks for your help Andrew, got it working with the Uno on a breadboard now. I would like to build the PCB version. Do you have the PCB file and does anyone know of a company that will make the board in the UK. I might even have ago myself if its too expensive, I use to make simple PCB’s years ago using transfers and a special pen, but not as complicated as this one.

    Reply
    1. Andrew Post author

      yes, you may find the PCB file in the repository and you may fabricate at OSH Park. Make sure to solder transistors backwards. On Nov 3, 2014 12:50 AM, “Speedy Signals” wrote:

      >

      Reply
      1. denver

        Thanks, when ordering the PCB, does it come with the holes all drilled or is that something we have to do. Ive never ordered a PCB before.

  35. troysbucket

    Ok I got my new parts and I’m using my final board to see if I can get this thing going. My first of two issues is that I’m not quite sure why the motion detector isn’t working for the most part. Sometimes I’ll see it work, and then the next time it won’t react. Then sometimes if I remove the motion detector GND (outside lead on the PCB) they’ll come on.

    Also I don’t know why they aren’t all activating. In the video below they all turn on when I hit the reset, then only some of them come on for the cascading light.

    Note: I was saying “male jumper” when I meant “male lead(s).”

    Reply
    1. Andrew Post author

      Congratulations, it works!

      If you compare your motion detector and the one in my video, you will notice that yours is different. Assuming that it works the same was as mine, there is a slight delay period after a “motion detected” event in which the motion detector will no longer output a pulse. It might be on the order of 10-30s, which is why it took a while for it to activate in your video. To test this, I would connect the output of the motion detector to an LED and time how often you can actually make it output something.

      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

      The initial power-on fade in and out is a test to make sure all lights are working. It uses the code ShiftPWM.SetAll. All of your lights fade in and out which means the hardware is correctly assembled! After this, the regular stairs mode activates and references the variable
      const int NUMLEDs = 9; which is why only the LEDs up to #9 light up. Change this to however many lights you have.

      Reply
  36. TTUram

    Thank you so much for sharing this. I’m a mechanical engineering student and chose to do this for my final project in my controls class.

    I downloaded eagle cad and want to fix the PCB transistor pins. Do I simply switch the ground and the JP pins?

    Any other recommendations on “fixing” the PCB?

    Reply
    1. Andrew Post author

      Glad I could help. Because you asked, I have uploaded a new version of the PCB. Check the post. If you choose to print it, you will be the first.

      Reply
      1. TTUram

        Thank you! I really appreciate it. I was messing with it last night for a few hours and finally got the hang of Eagle 7.1.0.
        I found this library for the 2N7000 resistor which I imported into Eagle: http://tangentsoft.net/elec/parts/eagle/files/transistors.lbr

        You mentioned you use a 7805 regulator. If I was to modify the schematic/PCB to add a Barrel plug for a power adapter, instead of the screw terminals you use, do I put the + from the power on the input of the regulator, ground to ground and then the output of the regulator to 12V (pin 24 on the arduino)?

        And is this the correct regulator: http://www.taydaelectronics.com/lm7805-l7805-7805-voltage-regulator-ic-5v-1-5a.html? I’m planning on lighting 15 steps.

        Thank you again!

      2. Andrew Post author

        Good! Learning EAGLE is a very valuable skill.

        Generally you connect regulators like this http://screencast.com/t/Y7MPUBO7cgt and pin 24 receives any voltage above 7V. There is already a regulator on the Arduino Pro Mini. It should not fry since current consumption is low.

        Yes that is the correct regulator–although you will have to add it to the PCB yourself.

  37. troysbucket

    Ok I got the correct number of stairs, and while I bought two of those PIR motion sensors that might be different than what you have, I also did buy another one from Radioshack, which might be the ones you have (there’s a GND, OUT, VCC header and no place to adjust sensitivity).

    What I did notice was that the ones I got online and the Radio Shack ones have the OUT and VCC pins switched. If the outside pin on the PCB (furthest one to the edge) is the GND, which ones are the other two?

    I also noticed in your code there’s variables for light threshold and other things. I have not changed any code aside from setting the NUMLED to 12 (my # of stairs) and I have no switch or photoresistor. Is there some code that I might need to change to make these things go off more often or adjust the sensitivity in the code? (I remember you mentioned earlier that the little adjustable dials on the PIR motion sensor don’t have any effect when they’re plugged in.)

    Reply
    1. Andrew Post author

      It is not possible to set the sensitivity or frequency of the motion detectors from the Arduino code. In this case, the dials DO matter if they exist.

      On the schematic (the white background) , observe that MOTION1 is connected with pins VCC, MOTION, GND in that order.

      On Mon, Nov 10, 2014 at 1:01 PM, Speedy Signals wrote:

      >

      Reply
  38. Waseem

    Hey Andrew, i am a computer programmer and i’m tired of it ,i am trying to give your project some of my time ,and i’m really interested in building this project , i would appreciate much if you write me down a list of all the component that is needed, and Btw i have arduino uno laid somewhere in my lab can i do it with arduino uno ,is the connections going to be different , how ?and how much is the pcb board gonna cost me ?i already have lots of Diy tools, and can i shrinkify this product ?it’s been boring all these weeks i am trying to find something to do :”)

    thank you for advance and i wish you all the best in your future projects

    Reply
    1. Andrew Post author

      I have added a new “Assembly” section to the post. I hope it helps. You can definitely do the project with an Arduino Uno if you are ok with wires everywhere. The wiring is the same. You can shrink the project by copying the board files and replacing all the components with SMD versions. However the connections to the LEDs are going to take up so much board space that it is almost pointless to use SMD parts if they are harder to solder.

      Reply
  39. troysbucket

    I’ve gotten everything hooked up and ready to go. JP1 to JP12 (1 is bottom of stairs) and I had motion 1 to the bottom of the stairs and motion 2 to the top. When I plugged it in I found that motion 1 and motion 2 were reversed (but it worked)!

    So I straight up swapped (GND to outside, VCC on right side, and OUT in the middle) and hit reset. After it’s warmup, if I trip the top or bottom of the stairs it lights up fine, and then is unresponsive. At one point the board sounded like it made a small clicking sound.

    Why would I work one time and then not another? I’ve tried reversing them back to normal, but it would only respond the first time. What am I missing? Are the connections bad? Is there something with the code I’m not taking into account (ex. I can’t have it sense anything for 30 seconds after I hit the reset button on the mini pro?)

    Also, I bought one of those laser sensor as well, and after plugging it in breaking the beam didn’t work.

    Reply
    1. Andrew Post author

      I have a theory and it may or may not be correct:

      Since the board has no moving parts, the clicking sound was probably an electrical component exploding. This is probably true considering it only turned on the first time.

      The voltage regulator on the board may have fried from overheating. You can check if this is true by measuring VCC. If it is more than 20% less than 5V then it most likely fried. If it has fried, you would have to solder an LM7805 regulator to the appropriate pins and maybe yank off the old one.

      *http://screencast.com/t/toT1SVBk0 *

      On Fri, Nov 21, 2014 at 12:55 PM, Speedy Signals wrote:

      >

      Reply
  40. troysbucket

    I had an extra PCB board made and switched it out with the previous one. When I was switching all the wires I noticed that the wire from the power supply to the PCB wasn’t secured too well, so that’s what might have made the snapping sounds.

    Anyway the new one looks like it works! (Most of the time!) The PIR motion sensor is pretty strong so even if I was in the kitchen or walking by the stairs it triggers the lights.
    Is there a way to change that?

    I also picked up a couple of those laser trip sensors and they don’t seem to work with your code (or with the circuit board) when I plugged them into the PCB. What changes does there need for the laser sensor to work?

    Also, What specifically does the code for the sensor do? If either sensor trips and continually “sees” motion (like someone doing jumping jacks in front of it) do the lights stay on? Is there code to recognize when someone passes the other side of the stairs (it see someone coming, turn on, and then wait for the bottom stairs to be tripped?) Sometimes when I trip it and then wait for it to go out and then walk by again it will NOT turn back on, is there an “off” timer that it needs to reset or something? Does it re-calibrate itself if there is extended motion in front of it so it doesn’t trip until another re-calibration?

    Reply
    1. Andrew Post author

      You can reduce the sensitivity of of the motion detector by restricting its field of view. I used a black piece of paper wrapped around the lens in a square tube about 3 cm long.

      The laser sensor requires a pullup resistor which you can enable in Arduino code by adding the lines

      digitalWrite(MOTION_SENSOR_TOP_PIN, HIGH);
      digitalWrite(MOTION_SENSOR_BOTTOM_PIN, HIGH);

      in setup() . You would also have to change the rising-edge detection to falling edge detection by switching the HIGH and LOW to LOW and HIGH in the lines that read

      if(pinRead == HIGH && lastReadTopPin == LOW){

      The code does not do person tracking and simply turns on for thirty seconds when either of the motion detectors are triggered. There is no limit to how often this can happen in the code–i.e. if the lights turn off and another rising edge comes from the motion detector even after a second, they will turn on.

      However, there IS most likely a limit to how often the motion detector will output a rising edge. This is the “off timer” you are referring to. On the Radioshack motion detector this cannot be changed. There are other motion detectors where there is a small knob to change this duration like (http://www.electrodragon.com/product/pir/) but I did not recommend them because I never used them myself. If I understand correctly, the laser sensors are pure analog and have no such timer built in.

      Congratulations on the successful implementation! Your video looks very nice. I am glad I was able to help someone build this.

      Reply
      1. TTUram

        Thank you so much for continuing to help us all out.

        I ordered all the parts you’ve listed but the PCBs haven’t even shipped yet and, if you remember in my previous comments, I’m doing this for a class final project. The project is due tomorrow (actually today in about 12 hours!) so I just did half of it on a bread board. Pics here: https://www.dropbox.com/sh/dncsxo0mh3cl44x/AACMEqhMVbyOL9DC8wLjMf6Va?dl=0

        I only did 1 Mosfet just so I can demo it for my presentation until the PCBs ship.

        I am using the lasers and just changed the code which now looks like this:

        /* Added the two lines you’ve recommended:
        /* Turn on pullup resistor for switch */
        digitalWrite(SWITCH_PIN, HIGH);
        digitalWrite(MOTION_SENSOR_TOP_PIN, HIGH);
        digitalWrite(MOTION_SENSOR_BOTTOM_PIN, HIGH);
        ShiftPWM.SetAmountOfRegisters(numRegisters);

        /*Switch High and Low:
        void loop()
        {
        /* Detect rising edge with polling. Interrupts crash the program. */
        unsigned char pinRead = digitalRead(MOTION_SENSOR_TOP_PIN);
        if(pinRead == LOW && lastReadTopPin == HIGH){
        topActivated = true;
        }
        lastReadTopPin = pinRead;
        /* Detect rising edge with polling. Interrupts crash the program. */
        pinRead = digitalRead(MOTION_SENSOR_BOTTOM_PIN);
        if(pinRead == LOW && lastReadBotPin == HIGH){
        bottomActivated = true;
        }

        Does that look correct?

        I tried it before adding those lines and supplied the board with 12v 1300mA (only thing I’ve got at home) and the lights flickered and did some funny business then turned off. I’ll mess with it more tomorrow (It’s 3:30am now).

        The lasers came with resistors, do I have those connected properly? They’re in between VCC and the Laser’s red wire. I have the Black wire to ground and the Blue wire to A2 for laser 1 and A3 for laser 2.

        On the schematic and board you have the photo resistor going to R1, that’s the photo resistor itself right?

        Also I haven’t added the switch (ordered the wrong one), so what modification do I need to add to the code to get it to work without the switch?

        Any and all help would be extremely appreciated!

      2. Andrew Post author

        I apologize that I could not help you before your project was due. I don’t have much free time.

        Those pictures were quite helpful. I could tell that the laser is not connected properly. The red wire is supposed to be connected directly to VCC. The resistor is meant to be connected between the red wire and the blue wire. It is called a “pull up” resistor because it pulls up the blue wire to VCC. But the digitalWrite() enables you to not use the resistors at all.

        Yes the code looks correct.

        It looks like you didn’t finish the photo resistor but it should be connected 5V > photoresistor > resistor > GND. No R1 is not the photo resistor, it is the matching resistor. If you have one resistor by itself, then there will be nowhere to measure a voltage between 5V and GND.

        The switch is not necessary for the code to work normally–it just keeps the lights on. You can use a wire or button instead of a switch. And if you want to be fancy, you can connect SPDT switches at the top and bottom of the stairs as the first and last switches in the “switch based XOR” I have here:

        https://speedysignals.wordpress.com/2013/06/27/how-to-switch-a-transistor/

        The MOSFETs are connected correctly but by not using resistors you might fry either the MOSFETs or LEDs. I did not put resistors on the schematic because the LED strips I used in the video already come with resistors.

        On Wed, Dec 3, 2014 at 1:31 AM, Speedy Signals wrote:

        >

  41. troysbucket

    Do you think you could like a picture of the tube and black paper that you’re using? I’m unclear as to how you have this set up and what material specifically you are using. I get the idea, though, to narrow the field of view.

    Changing to the laser sensor would be cool, but I think one of them broke already, and it might drive my cat crazy.

    It’s pretty responsive, but there are those rare times when someone has just passed it and after it turns off it won’t detect that rising edge again. I’m hoping that if I narrow the field of view then when someone intentionally gets close it will trigger.

    Do you think you could go into detail on adding the switch (or do you just solder it?) and the photo sensor? I think it would be good (and up to electrical code) if the top and bottom were on when it reaches a certain time of day. I have no idea how to even measure the ambient light, let alone which leads to solder or where to place the sensor.

    Reply
    1. Andrew Post author

      I used black construction paper and wrapped it around the motion detector. I would provide a picture but I am not at home anymore.

      Adding the switch is just soldering a switch. Any switch. Try one SPST switch first. Then if you want to be fancy then you can connect SPDT switches at the top and bottom of the stairs as the first and last switches in the “switch based XOR” I have here:

      https://speedysignals.wordpress.com/2013/06/27/how-to-switch-a-transistor/

      For the photosensor, first point the photoresistor at the light. That means don’t put it in a box. Then connect 5V > photoresistor > 10k resistor > GND and then read the analog value at the time you consider the border between day and night by inserting the following line into loop():

      Serial.println(analogRead(PHOTORESISTOR_PIN) );

      You should get a number between 0-1023. Then you replace the value in the line

      const int LIGHT_THRESHOLD = 300;

      with that number. Or you could just leave the photoresistor out and have the stairs trigger all the time.

      For the “first and last always on”, all you would need to do is replace both instances of

      ShiftPWM.SetOne(abs(l), brightnesses[abs(l)]);

      with

      if(l == startLight || l == endLight){ ShiftPWM.SetOne(abs(l), maxBrightness); } else { ShiftPWM.SetOne(abs(l), brightnesses[abs(l)]); }

      On Mon, Dec 1, 2014 at 6:37 AM, Speedy Signals wrote:

      >

      Reply
  42. Toby

    Hi, great project

    I’m on progress to builded it.
    Just one questions :
    Is it possible to replace N-Mosfet with regular NPN transistor (i.e 2N2222) ?
    cause it’s hard to find in my country

    -Toby

    Reply
    1. Andrew Post author

      Cool! I hope you can build it successfully.

      No you cannot replace the MOSFET with a BJT. It is not supposed to work but it might because of the output current limit of the shift register. I would not recommend it.

      You can use another N-channel MOSFET, even in an SOT-23 package.

      Reply
      1. Toby

        Hey..It’s working.. (my friend’s gave me the Mosfet)
        I used 9 led for the first time and everything’s ok.
        Then I made up to 14 led.
        I changed the code to

        const int NUMLEDs = 14;

        Problems :
        – 14 led fade in then sequence.
        – Then all led Stay on

        I reprogram to 9 led, everything’s ok, back to normal
        – All Led fade in then squence
        – All led off
        – motion sensor detect movement
        – Led sequence

        Did I missed something for the code ?

        -Toby

      2. Andrew Post author

        Apologies for the long wait. As far as I know, NUMLEDs is the only thing you need to change. All the lights turning on will occur if you have pulled down pin 2 with a switch, but otherwise everything should act just as if there were 9 steps. I personally have thirteen on my staircase. I will pull out the board later this week when I return home.

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 )

Connecting to %s