Introduction: Stair Lighting With Motion Detection and Following Lights

Picture of Stair Lighting  With Motion Detection and Following Lights

Hi there,

(this is my first instructable and english isn't my native language)

i've made a stair lighting controlled by Arduino and triggered with two motion detectors.

The lights are WS2801-Stripes -cutted and re-aranged.

It took me way more time as i would have expected. But to be honest, i didn't knew much about programming at all.

The result is a lighting which runs in front of you and gets off behind you. Stair by stair. Triggered with motion.

I've played around with ultrasonic and photocell. But none of them worked as good.

So: let's go.

Step 1: Materials and Skills

Picture of Materials and Skills

-WS 2801

At least as much WS2801-LEDs as stairs.

I've used 26 LEDs, with two on each stair. 13 Stairs -> 26LEDs.

- adrduino

An Arduino. A nano or smaller will do. We only need a hand full of in/output pins.

-LED-Corner-Adapters

i don't know how to translate, so on top is a picture of them.

-Wires

reusing old IDE-Cables from computerparts is a good start. They are flat, and you can solder them.

And jumper-wires to make a detachable system.

-Box

To hide everything, i've cleaned a battery-holder and put all the electronics in it.

That way i could make it all detachable to programm it.

Magnets

My railing is made of steel, so magnets are a good way to stick things at a place

Most of my magnets are from old harddisks.

Detection Sensors

- you need two of them. Any will do which are compatible with arduino or a raspberry

... and of cours a soldering station, soldering iron and something to measure.

Step 2: Make a Plan and Think It Through

Picture of Make a Plan and Think It Through

At first start to think about, how the light should "work".

My lights shine on the wall and the reflecting light shines back to the stair . So it's all indirectly.

Another way would be to attach the lights directly under the stair. But that way they could dazzle and you will probably see them, even when they are off.

So .. think of it, measure it and write everything down.

Step 3: Soldering

Picture of Soldering

So now you've got all your dimensions you need?

Start cutting youre desired number of LEDs per stair, bring them in a 90° angle and solder them to your LED-Angles. (First picture). Repeat untill all are done. (second picture).

!Be aware of the direction! There should be an arrow printed on each part.

Now get your IDE-Cables, cut them, and solder them again in a 90° angle to your LED-Angles. (3. picture)

And now LEDs to Angle to IDE (4. picture). As you guessed: 90°

Be as exactly as possible. When its all done, you'll end up with an stair-like chain of lights.

When you are in reach of a multimeter, it's now a good idea to measure it all through.

The + and - V will "beep" through. The data and clock will only show numbers (no beeping).

Step 4: Box

Picture of Box

All electronics fit into an AA-Battery holder.

Just get rid off all stuff in it and drill a hole on each site (for usb connection). (picture 1-3)

My magnet from an old hard-drive fits too. Arduino and magnet are fixed with double-sided glue from 3M. (4)

To get electricity to every part i've taken a pinheader. First three will be "-", last three will be "+".

Fits in the box just perfectly. (6).

Good time to destroy some jumper-cables (or to use them not as intended).

Take 8 male/female with different colours. Cut them in half. Choose one side (male or female) and put the other side away.

Two of them need to go through the front, where the usb-port looks through. Those will be the powerwires.

6 of them need to go through the back. They will bring out some electricity, data and clock.

Bring them in place and write down your colour and your pin.

On your arduino you'll need pin 2,3,5,6, power and ground. (So 6 to go out on the left.)

You can take any colour and any pin. This is just what i've used and how the code is used.

The arduino needs power too, so the little pinheader comes in now. "-" to the left. "+" to the right.

Again. i've used old IDE-cables. (the grey cables in the picture)

In the end it should look quite like picture 9. You can use some hot-glue to hold all wires in place.

My colours and used pins:

brown: -

red: + (5 Volt)

blue: data (WS2801)

white: clock (ws2801)

orange: data motion sensor 1

green: data motion sensor 2

Step 5: Connecting to Stair-chain of Lights

Picture of Connecting to Stair-chain of Lights

On the left/outside of our little box we'll need to connect everything to the chain of lights and the motion detectors.

At first: connect the second detector with volt and ground to the end of the chain.

The power goes right through the chain, so you can get it from there.

The data need to be connected with a seperate wire. Probably a very long one. To use my coloursystem: orange wire. Make it as long as needed in your case.

The WS2801 needs 4 connections. +5V, ground, data and clock.

Red: +5V

Brown: ground

White: clk

Blue: dat

There could be printed something else on your stripes, but you will for sure find out, which is which.

The last cable (green) goes straight to data on the first motion detector.

Power:

In my case i'm going into the first detector, from there to the box and from there out to the lights and the second detector.

You can probalby use the usb-connection from the arduino to power it all, but be carefull, how many LEDs you use. Too much could kill your arduino, when powered through it.

The save way is to use a seperat connection for power.

By now it's running with a powerbank, because i didn't yet find a way to get constant power at that place without drilling holes in our walls.

Step 6: Programming and Testing

Picture of Programming and Testing

Arduino IDE installed?

You'll need the Adafruit_WS2801.h library, too. So go and get it now.

......

Fine, all you need is the attached code and flash it.

In Line 28 you can change the speed from up to down.

In Line 37 you can change the speed from down to up.

In Lin 46 you can change the ON-Time, when it started from "up".

In Lin 53 you can change the ON-Time, when it started from "down".

The timing now is how slow i walk :)

The Stripe will light up immediately. So if you are using a lot of LEDs, you should power them external AND push out your USB-connection.

Test it, if all works as expected. Maybe you've reversed blue and white? No problem. Change the code or the wires. You won't destroy anything. Believe me. I've made all of it wrong and nothing went into flames.

I've used paper-rolls to get a "real" detection from each motion-detector.

Step 7: Get It on Your Stairs

Picture of Get It on Your Stairs

To hide all cables i've choosen a self sticking film from avery fascal.

It's black matte (820). You can get it from ebay or a local signmaker. Its very durable.

To bring all LEDs in the same place you can use a piece of cardboard. Cut it in your desired lenghts (90° ;) ) and you can use it for positioning.

My box [1] sticks under the rail. Magnets.

The seonsors are "hidden" under the first stair and the rail. To find the best position, you will have to test and test and test...

That's it. It is easy to modify in any way. Even the colour could be changed.

The biggest problem: get all wires as long as needed. Not to short, not to long.

I have to say THANKs to ClaudiaF from kodinerds.net. The code is all from her.

Comments

KairulB (author)2017-05-29

Nice work on your staircase! I wanted to build with RPi or Arduino but don't know how to increase the output so I bought a lighting controller made by another Instructable user. Same thing sensor at the top and bottom and the stairs turn on one step at a time from top or bottom. Also they dim up and dim down not on off.

chenboly (author)KairulB2017-08-21

Hello, Do you have full instruction including the materials?

thanks.

donc146 (author)2017-06-06

If you want another colour, there has to be some code to be changed:

#include <Adafruit_WS2801.h>

#include <SPI.h>

uint8_t dataPinStrip = 3;

uint8_t clckPinStrip = 2;

uint8_t bewegung1 = 7;

uint8_t bewegung2 = 6;

uint8_t bewegungsstatus = 0;

uint8_t num_LEDs = 24;

uint8_t hue = 0;

uint32_t c = 0;

int abstand = 0;

Adafruit_WS2801 strip = Adafruit_WS2801(num_LEDs, dataPinStrip, clckPinStrip);

uint32_t Color(uint32_t r, uint32_t g, uint32_t b)

{

return ((((r << 8) | g) << 8) | b);

}

void lights(boolean order=true, boolean mode=true)

{

uint8_t r = 230;

uint8_t g = 5;

uint8_t b = 130;

int i = 0;

if (mode)

{

c = Color(r, g, b);

}

else

{

c = 0;

}

if (order)

{

for (i = 0; i < num_LEDs; i++)

{

strip.setPixelColor(i, c);

strip.show();

delay(200); //Anschaltgeschwindigkeit von oben nach unten

}

}

else

{

for (i = num_LEDs; --i >= 0 ; )

{

strip.setPixelColor(i, c);

strip.show();

delay(250); //Anschaltgeschwindigkeit von unten nach oben

}

}

}

void up()

{

strip_clear();

lights();

delay(8000); //Leuchtzeit von oben nach unten

lights(true, false);

}

void down()

{

strip_clear();

lights(false);

delay(8000); //Leuchtzeit von unten nach oben

lights(false, false);

}

void strip_clear()

{

for (int i=0; i < num_LEDs; i++)

{

strip.setPixelColor(i, 0);

}

strip.show();

}

void setup()

{

pinMode(bewegung2, INPUT);

strip.begin();

strip.show();

}

void loop()

{

bewegungsstatus = digitalRead(bewegung1);

if (bewegungsstatus == HIGH)

{

up();

{

strip_clear();

}

}

bewegungsstatus = digitalRead(bewegung2);

if (bewegungsstatus == HIGH)

{

down();

{

strip_clear();

}

}

}

This lines define the colour:

uint8_t r = 230;

uint8_t g = 5;

uint8_t b = 130;

donc146 (author)2017-05-30

There is a very small mistake in line 13.


  1. uint32_t Color(uint32_t r, uint32_t g, uint32_t b)

that's, how it should look like.

You can use the old code, untill you want red as a colour. Something abour shift-register.

So: it does work with the original code - but it doesn't, when you want red.

In that case you'll have to change that line with the one given above.

donc146 (author)2017-05-30

With a power-bank which should be capable of charging and dis-charging at the same time, it would be easy to make it power outage save.

Only thing to mention: the powerdraw while in "sleep-mode" is very low. The good powerbanks (anker) will go to sleep, if the powerdraw is below a certain limit.

Mine went to sleep after ~10 mins. My old powerbank doesn't have this feature, so it stays "on".

CapeScanner (author)2017-05-29

Awesome job! I've been looking for something like this. It would be nice to use during a power outage as well. Thanks.

donc146 (author)2017-05-29

Didn't even know that radar-sensors exist :)

I'll buy&try. Thanks.

DIY Hacks and How Tos (author)2017-05-28

Cool! I wish that I had a set of stairs that I could do this to.

About This Instructable

4,270views

126favorites

License:

More by donc146:Animated Psycho PicturePandora - Mobile Squeezebox LMS BoxUNMOMENT - ntp, binary, rgb CLOCK
Add instructable to: