Motion Activated Stairs

Published

Introduction: Motion Activated Stairs

About: I'm a 18-year-old high school student, I love engineering, film production, design and everything in between.

Yes, I know what you're thinking, this does seem a little overkill but first of all, you'll never have to worry about stubbing your toe again and second, it makes walking up and down your stairs so much fun, i found myself going upstairs for no reason just to watch the lights follow me. I mean it isn't the most practical project but its a fun build and it gives us a chance to learn about the different ways to activate lights with an Arduino. So with that being said, let's get started with the build!

Step 1: How It Works

So whats happening is as you walk up the stairs the step you're on, the step in front of you and the step behind you are lit up which allows you to see exactly where you're walking no matter which direction you're walking in, not to mention the cool effect it gives.

The way it works is each step has a laser and light sensor which makes a trip wire, when the laser beam is broken the Arduino triggers a MOSFET which turns on the corresponding LED strip. Now this definitely isn't the only way or even the easiest way to do this but the alternatives didn't work for me for a bunch of different reasons. The most obvious alternative was to mount an ultrasonic sensor at the base of the stairs and then turn on lights based on how far you are from the ultrasonic sensor, this didn't work for me because I have too many stairs! (14) which caused it to lose accuracy and turn on the wrong lights which made the whole process of walking up and down the stairs very disorientating. Of course, there was the option of just turn on your room lights but again that's just no fun.

Step 2: Parts List

Okay so the amount of parts you need is really dependent on the number of steps you have on your staircase, so if you see "dependent" it means you need to figure out how much you need for your stairs.

  • An Arduino Mega (Here)
  • Light sensors Dependent (Here)
  • lasers Dependent (Here)
  • Buck Converter (Here)
  • 12 Volt Power Supply (Here)
  • Mosfet Dependent (Here)
  • LED Strip (Here)
  • Looooots of wire

Now, I have 14 steps so I will be getting 15 MOSFETs, 15 light sensors, and 14 lasers. Make sure to always get an extra light sensor and MOSFET because we are going to use them for something else later.

Step 3: Wiring Everything Up

Since I have so many steps I'm going to have to wire things up one at a time to makes things a little easier, so let's start by wiring up our light sensors. Now you'll see on the light sensor that it has 3 pins, two of these are power (5 volts and ground) and the other is the source pin which gets plugged into the Arduino. The way to do this is we connect all the sensors power pins together in parallel and then into the Arduino's 5 Volt and Ground input, this will supply power to all the sensors. Then we are going to connect each signal pin to the Arduino's analog pins with the first light sensor getting connected to A0, second to A1, third to A2 all the way to the last which gets connected to A14.

Next, we are going to connect up the lasers, this parts pretty easy as all we have to do is connect them all in parallel just like we did with the power pins of the light sensors. Then we are going to want to connect the positive and negative output of these lasers to the positive and negative output of our buck converter which will be stepping down 12 volts to 5 volts for use by our lasers. Now the positive input of the buck converter gets connected to the positive output of our power supply, leave the negative connections unconnected for now as we are going to use our MOSFETs for that later.

Now we need to get our LED strip ready, the first thing to do is cut it into individual strips, then every strip will have its positive input soldered together and then connected to the positive output of the power supply then each LED strips negative input needs to get soldered to its own MOSFET but we will talk more about this in the next step.

lastly, we are going to want to connect the positive output of our power supply to the VIN pin on our Arduino and the ground output to ground on the Arduino.

Step 4: MOSwhat?

So when we think about turning on and off an LED using a microcontroller it seems pretty basic, all we do is making the pin its plugged into HIGH or LOW but things get a little more complicated when we want to power a bigger load like a 12 volt LED strip and so to achieve this we need the help of a MOSFET.

A MOSFET is really just a switch that can be turned on and off by a computer, you'll see that it has 3 pins, the first one is Gate, second is Drain and third is Source. When gate is made HIGH by a microcontroller it connects drain and source allowing the current to flow however when gate is LOW it breaks this connection stopping the flow of current, this allows our microcontroller to control these high power components without having to supply power to them.

So let's get to the wiring, we are going to need 15 N-channel MOSFETs (your stairs may need a different amount), 14 for the step lights and one to turn off the lasers when its daytime (this is also why we have an extra light sensor). We are then going to solder the ground connection of each LED strip to the middle pin (drain) of a MOSFET when this is done you should have the same amount of MOSFETs as you do steps, in my case, it's 14. Now we need to solder the negative input from the buck converter to the middle pin of the last MOSFET.

Now we need to solder the source pin on all the MOSFETs together, this creates a common ground which we can then connect to the ground output of our power supply and then lastly we need to connect gate on the MOSFET to the digital pin on our microcontroller, the MOSFET of the first light gets connected to pin 32, the second to pin 33, third 34 all the way to the last light MOSFET which gets connected to pin 45 and then the MOSFET controlling the lasers gets connected to pin 46, all of this will become more clear when we talk about the code in the next step.

Step 5: Code

The code can be found below but let's just take a second to see how it works so that you can adapt it to work with the number of steps you have.

So the first thing we see is the void setup, we are just stating that pins 32 to 47 will act out outputs turning the MOSFETs on an off, now if you have more steps be sure to add more outputs and if you have less remove some just make sure to keep the laser's output so we can turn them off during the day.

Next, you'll see the void loop which is where the beef of the code is, the first thing we see is that analog pins A0 to A14 are reading data from the light sensors, like before if you have more steps you need to copy and paste some of this or if you have less you're going to need to delete some.

Which brings us to our most important part of the code, the if statements. The first if statement states that if the value sent back from our light sensor in charge of checking if its night or day is below 220 to turn on the laser or if not to turn off the lasers. Then the second one (which is almost the same as all the following ones) states that if the light sensor from that step AND the day and night sensor both send back a low-value indicating that the light has been broken to turn on the MOSFET controlling the light for the step you're on, the step in front of you and the step behind you. Now if you have more steps you need to copy and paste these if statements and add the correct pins to it and if you have fewer steps you can just delete the if statements of the steps you don't need.

This does get a little complicated so if you have any issues what so every ill be happy to answer them in the comments or in private messages.

Step 6: Mounting Everything

Okay so at this point everything is almost done and ready to go all we need to do now is mount all the components to our stairs and make a case around our Mega! This is very easy to do with some cardboard and hot glue.

So let's start mounting everything, the lasers, light sensors and LED strips can all get mounted on each step making sure that the laser beam hits the light sensor right in the middle of the photoresistor, this can be accomplished with hot glue or any kind of adhesive that dries quick. Now we can give everything a final test before we secure all the wires in place with electrical tape to make it look a little neater. Now we need to mount our day and night sensor in a play that will get a good bit of sunshine during the day which will allow it to turn off the lasers.

Then a box can be built around the Arduino and MOSFETs to keep them safe and everything is just about done! If you have any issues getting this working or have any questions ill be available to answer them in the comments or in private messages!

Microcontroller Contest

This is an entry in the
Microcontroller Contest

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    2 Tips

    This would make it so much more complicated but a third option could have been capacitive sensors since you wouldn't have any lazers shining

    Hello I find this a nice project

    but I rewrote the code (had some spare time) hope you like it

    https://we.tl/KOozjotBdh

    its not perfect but should work if not or you want explanation don't be afraid to contact me ;)

    4 Questions

    So.... Random Thought...

    If I added a sub-system to this that could be activated and deactivated (by a switch or remote or something) and I placed a small amount of explosives under one stair....

    Basically a disguised tripwire system to disable home intruders.

    And then I add a landline, that only calls 911, at the bottom of the stairs for the intruder to call an ambulance in the event that I'm not home.

    Is this morally acceptable and does anyone else like the idea?

    0

    Do you need different receiver sensors for IR or can you use the ones in the description

    0

    Instead of lasers could one use IR diodes?

    I have had the idea of a similar project, but for outdoor steps leading up to my deck. Any recommendations for an outside application?

    15 Comments

    This is a fabulous project! Really fun/well executed--I don't have a stairway where I could do this, but now I want one!!! Well done and thanks for sharing this one.

    Hey, cool!

    I've been planning to do something similar, but my plan is to only use laser trip sensors at the top and bottom of the stairs. I will have a delay setting for turning off all the LED-strips mounted under the "nose" of each step. So when either of the trip sensors is triggered the whole staircase will light up and be illuminated a few seconds longer than it takes to go up (or down) the stairs, in my case about 8 sec. If someone else trigger the sensors within the 8 sec the delay time is renewed. The trip sensor do not have an off function at all.

    I think I will use a relay that is triggered by the Arduino so the load of the strips doesn't have to go through the micro controller. I would love to have the lights ramp up and ramp down instead of just on/off, but that requires some kind of hardware after the relay driving the LED-strips.

    I will also incorporate a light sensor for ambient light, since there is a window in the staircase and sometimes the stair lights are turned on. This way the LEDs will only light up if the stairs are dark.

    2 replies

    I suggest using Mosfets and either a Arduino with enough pins (stairs+2) or some other control mechanism like shiftregisters.

    If each ledstrip is connected to its own pin its easy enough to write the code.

    The LED-strips need a lot of power, so I think that I will need a relay that can channel the power from a stand alone power supply. The code is really simple; when one of the trip sensors is triggered--->pin X High, Delay X sec--->pin X low. "Pin X High" trigger the relay and all the LED-strips light up for X sec and then "Pin X Low" will shut them down.

    It's been a while since I wrote the code and tested the setup on a breadboard, but it worked like a charm! I even had a tiny relay to test the function. The drawback is as mentioned that the relay is just on/off but I'll to do some research to find some device that can ramp the voltage after the relay.

    I like this instructable! I'm curious, how does it react when more than one person is on the stairs? One coming up and one going down or two people following each other?

    2 replies

    I have looked at the code and it should light up for more people but in a not so clean way but I have reworked the code and now it should support that

    Awesome and thanks!

    "Yes, I know what you're thinking" - That it looks like a scene from the excorsist? lol but yeah, awesome idea :)

    Thoroughly disappointed. I saw that title and thought the stairs moved somehow.

    Oh well. It's well done and "Arduino Controlled Stair Lights" are a great idea.

    I couldn't do this though, my dogs would go out of their minds.

    Very neat idea!

    (It would be pretty creepy if when you went to go down the stairs, they started lighting up from the bottom coming up towards you)

    1 reply

    Good instructable. We have a stair case I would like to light up pretty much as you have done. It is a real hazard at night. I actually count stairs to keep out of trouble. So a personal thanks for your effort

    1 reply

    This is awesome. Love the idea. My parents could use this setup for their basement stairs.

    1 reply