loading

You know how it goes - you wake up in the middle of the night to go to the bathroom, can't see anything, and knock something valuable over. Or, you come home late, the lights are already off, and you stub your toe trying to find the switch.

No longer! We've solved the problem of late-night lighting in a hands-free way that's stylish and won't disturb your roommates.

Like this Instructables? Check us out on Facebook!



Introducing the Automatic Hallway Runner Lights.

Total project time: 3 hours

To get started, you'll need the following parts:

Some tools:

  • Breadboard for prototyping
  • Soldering iron (and solder)
  • Wire strippers/cutters
  • Heat gun (or hairdryer, or lighter)
  • Hot glue gun (to secure loose wires)

Step 1: Build the circuit

Now that you have all your parts in hand, it's time to build the lighting controller!  This circuit turns the runner lights on or off depending on the current light levels in the hallway (detected by the photocell) and the presence of a moving object (detected by the PIR sensor).

Step 1: Headers
We want to mout the arduino to the protoboard using two of the female header sockets. Align two of the headers so that pins D7 to TX and A2 to VIN will be connected to the board when the arduino is plugged in, then solder them in place. Next,  take another 10-pin female header and cut it into two 2-pin sockets and one 3-pin socket. Install these three sockets; the photocell and LED strip both need two pins, and the PIR sensor needs the three-pin socket. 

Step 2: Cables
We wanted the PIR sensor and photocell to be mounted pretty far away from the board and the LED strip - about 10 feet away! If you want everything near the PCB, you can skip this part.

We'll need to create two cables - one for the PIR sensor which has 3 wires, and one for the photocell with two wires. The photocell is easy - just cut a 10-foot length of our 2-conductor stranded wire. Strip one end and separate the leads before slipping some heat shrink tubing on for later. Then solder the two leads of the photocell, move the heat shrink over the solder joints, and heat it up to ensure a solid, insulated connection. For the other end, break off a 2-pin segment of the male header pins, strip the two conductors and solder each conductor to one of the pins. Add some some hot glue around the solder connection to ensure nothing will accidentally short these two leads.

It's a similar process to create a cable for the PIR sensor, but this time we want to use our 3-conductor stranded wire for each of the pins of the PIR sensor. Follow the same steps as before, but Instead of soldering the PIR sensor directly to the wire, cut a 3-pin female socket segment and solder this to the cable instead. The pins of our PIR sensor should fit nicely into this socket.

Step 3: Connections
Use your iron and some solid core wire to install and connect the remaining parts as indicated in the diagram.

Some justifications:
Our PIR sensor's output pin reads 0V when no motion is detected and 5V when it senses a moving object. We could just feed this value straight into a digital input pin on the Arduino Nano, but we noticed that there was a large drop in power due to the 10'+ of wire we used to put the sensor in place. Instead, We hooked the sensor up to A6 and used analogRead() to check if the voltage is above or below a certain threshold. 

The photocell is triggered in a similar way - combined with the resistor, it acts as a voltage divider. When there's a lot of ambient light, the photocell has low resistance and we see a low voltage; in the dark, we see close to 5V.

When we send a digital HIGH (5V) value on pin D3, that saturates our MOSFET and allows current to flow through the LED strip. The 100kOhm resistor attached to its gate acts as a pull-down, so that our LEDs actually turn off if the gate ends up floating. 

Advertisement

<p>Loved it, Made it. Post it. </p><p>My PCB Board:<br><a href="https://www.oshpark.com/shared_projects/CWC2JxKg" rel="nofollow">https://www.oshpark.com/shared_projects/CWC2JxKg</a></p><p>Hope you dont mind my putting in your logo the show inspiration</p>
<p>very good that your board, but I wonder if I have to do some modifications to the code to run on your board</p>
The code is based but quite different from the one on this page. Not only because of the Attiny85. I wanted to make it a bit simpler for my own understanding. I connected it and haven't looked back at it since (except to illuminate the way). The code:<br><br>const int transistorPin = 0; // connected to the base of the transistor (LED Strip)<br>const int buttonPin = 3;<br>const int ldr = A1;<br>const int pir = A2;<br><br>byte sensMotion = 0; // variable to hold current state of motion detector<br>int LDRReading = 0; // variable to hold current state of photocell<br>int buttonState = 0; // variable for reading the pushbutton status<br><br> void setup() {<br>// Serial.begin(9600);<br> pinMode(transistorPin, OUTPUT);<br> pinMode(ldr, INPUT);<br> pinMode(pir, INPUT);<br> pinMode(buttonPin, INPUT);<br> }<br><br> void loop() {<br> sensMotion = digitalRead(pir);<br> LDRReading = analogRead(ldr);<br> buttonState = digitalRead(buttonPin);<br> <br>// Serial.println(LDRReading);<br> if(sensMotion == HIGH &amp;&amp; LDRReading &lt;= 100){<br>// Serial.println(&quot;Sensor tripped.&quot;);<br> for (int brightness = 0; brightness &lt; 255; brightness++) {<br> analogWrite(transistorPin, brightness);<br> delay(10);<br> }<br> <br> delay(10000);<br><br> for (int brightness = 255; brightness &gt;= 0; brightness--) {<br> analogWrite(transistorPin, brightness);<br> delay(10);<br> }<br><br> delay(2000);<br> }<br> <br> if (buttonState == HIGH) {<br> // turn LED on/off:<br> for (int brightness = 0; brightness &lt; 255; brightness++) {<br> analogWrite(transistorPin, brightness);<br> delay(10);<br> }<br> <br> delay(5000);<br><br> for (int brightness = 255; brightness &gt;= 0; brightness--) {<br> analogWrite(transistorPin, brightness);<br> delay(10);<br> }<br> }<br> }
<p>Looks awesome! Thanks for the attribution :)</p>
<p>Awesome stuff! I'd like to use this to switch a TV on and off. I'm new to this stuff so please bare with me</p><p>I currently have a droidstick showing artwork from a twitterfeed on a dedicated tv in the livingroom which at the moment switches on using a regular timer in the power socket. Works great but does waste a bit of power if there's nobody there to enjoy the art, so I'd like to replace the socket timer with something like this creation using an infrared sensor or something so it switches on or off depending on whether there's someone in the room. </p><p>Is it just a matter of replacing the mosfet with this one: IRF840?</p>
<p>Hi Richard - sounds like a cool project :) <br><br>It sounds to me like you're trying to switch AC using a MOSFET - chances are this won't actually work and may damage both the circuit and your TV. I'd highly recommend using a relay instead, as these are designed to take AC loads. There are even solid state relays (SSRs) that can take tens of millions of cycles before failure and don't have that clicky sound when they turn on.</p>
<p>Wait Wait Wait... An Arduino Nano is $20 (&pound;14)?? I thought paying the &pound;3.50 ($4.90) was a bit steep (though with free shipping).</p>
<p>Yeah, in hindsight that was a pretty steep markup for a cheap little micro... the things you learn in 3+ years ;)</p><p>Thanks for pointing it out though - updated the pricing.</p>
<p>Nice one.. I felt a bit of a d*** for leaving that message after pressing enter key, but there was no edit, and delete kept failing. I am glad you didn't take it the wrong way. Nice project. I plan on doing something very similar but to the stairs.. I did have the idea of doing each step individually, but your project given me the idea of just doing the skirting board down the stairs. </p>
<p>What is the power draw when lights are off? Is this something to turn off in the daytime in other words? I am just curious if you have had a chance to measure the sleeping status of the circuit?</p>
<p>Haven't measured it directly, but the quiescent current of a PIR sensor is in the range of microamps. The nano uses &lt; 1mA when active (<a href="https://www.reddit.com/r/arduino/comments/14hsiz/how_do_i_figure_out_the_power_consumption_of_an/">https://www.reddit.com/r/arduino/comments/14hsiz/h...</a>) so you're probably looking at spending under $0.01 per year for any idle time. </p><p>If you're counting converting AC to power it, that'll probably be higher, but the cost varies wildly depending on the efficiency of the adapter used.</p>
<p>While this is a great project, you don't need a computer to light up an LED.</p><p>Get one (or many!) of these PIR (motion detector) modules from eBay: </p><p><a href="http://www.ebay.com/itm/10pcs-HC-SR501-Adjust-IR-Pyroelectric-Infrared-PIR-Motion-Sensor-Detector-Module-/131028677440?hash=item1e81eaf340:g:MXQAAOxyA9dSaN2m" rel="nofollow">http://www.ebay.com/itm/10pcs-HC-SR501-Adjust-IR-P...</a></p><p>They have a switched output that will switch a highly efficient LED (quite bright) on when there is motion, and they have an adjustable delay before they go back off.</p><p>If they don't already have one, you can add an LDR (light dependent resistor) so the gadget doesn't turn the light on in the daylight hours or if the main overhead light is on.</p><p>No programming, and the only wires would be for a power connection unless you can run it on a local battery.</p><p>Great project here, but you don't need that much light to find a wall switch in the dark.</p>
<p>We actually used a similar sensor to that one for this project - but we wanted to go a bit more artistic. There's a huge difference between bang-on, bang-off for a single LED and slow-fading strip accent lighting. </p><p>Different strokes, I suppose :)</p>
<p>You don't even need a PIR to light up a LED. I have a piece of 12V strip that I added an extra LED to, and it runs around ten MA I think. Which is about the running current of a PIR detector. So I just leave them on all the time. It costs me about 20 cents a year, I figure. </p>
Very nice. Thanks for sharing.
<p>The overall idea is really clever. However, having to run wires around the door frames isn't too appealing, at least for me.</p><p>As suggested by someone else, by installing PIRs at appropriate locations, close by an electrical outlet, and adjusting the sensitivity and delays, you would have something fairly functional too.</p><p>Obviously, you would lose the potential flexibility of the microcontroller, but on the other hand, what is needed is only some lightning for specific needs, nothing exhaustive.</p><p>As per my past experiences, the SR501 PIR sensors aren't reacting exclusively to movement. In the past, I had one installed just above a door on the back of my garage, which was triggering when the dogs were entering or leaving the garage. During the summer, the door was left open and only the warm air flow was sufficient to trigger the PIR. In fact, any meaningful temperature variation was sufficient to get the PIR in action, so cold to warm or warm to cold, would trigger it. Finding the appropriate setting to accommodate the needs, might become somehow time consuming, but it's fun when everything is working.</p><p>Movement detection and light detection always lead to interesting little projects.</p><p>Don't come back home too late, just in case someone swap the lights for an alarm and you'll end up having an hearth attack ! ;-)</p>
Interesting... I've heard red light is best for night vision, but not 505nm. I'll definitely take a look at this the next time I need low-light illumination. Thanks!
<p>Red light is best if you don't want to sacrifice your night vision.<br>Other colors (Green?) are easier to see in low levels.<br>Basically, your eye is more sensitive to certain colors, so those colors give the most detail at low levels, but they also lower your ability to see in the dark after you switch the light back off.<br><br>Example, inside a tank at night you would want red instrument illumination so that when you look outside you can see well (moreso in the days before enhanced / amplified night-vision goggles).<br><br>I think the blue lights in car instruments are a mistake - but I grew up when headlights weren't blindingly bright.</p>
bagus banget..
how easy is this project?
Should only be a little bit tougher than your light-up skateboard project :) finding the right thresholds for the PIR detector and photosensor was the toughest part, and that was just trying different values.
ok thanks for the info!
Did something similar years ago using an outdoor security sensor light, but I like having all the possibilities the Arduino gives you, as robomaniac says.Good job !!
Thanks - glad you like it!
An Arduino (We used a Nano) where did you buy <br>
Bought mine from Amazon (<a href="http://www.amazon.com/SainSmart-Nano-v3-0-for-Arduino/dp/B00761NDHI/ref=sr_1_2?ie=UTF8&qid=1384956807&sr=8-2&keywords=arduino+nano" rel="nofollow">like this one</a>)
Hi, can i install 2 PIR Motion sensors ? I want to make this project for my stair case. Thanks!
Awesome idea! Yeah, you can just copy the circuit involving the first PIR sensor and put it on a different pin on the arduino. Then change the code so it reads both sensors and takes the OR of the two (so if you detect motion from either one, turn on the lights).<br> <br> I'd love to see a finished build when you make it!
so good proyect but i have a cuestion , how to do it witout an arduino ? can be made instead with a infra red detector pair, a timer and a little power bus for the leds ? <br> <br>regards from mexico
Yes, you can do it with a LM555 timer, light sensor, and discrete components (check out http://www.buildcircuit.com/modes-of-ne555-monostable-and-astable/). You have to modify this if you use both a movement sensor and light sensor to detect motion and light, though - it only uses a light sensor to turn on a light when it gets dark.
Hi, I`m new in electronics so, can I use another type of Arduino ? Like Arduino Uno V3 ? Also, I have another question, from diagram, JP1 and JP2 are the same pins from Arduino? Please answer me .
Of course - an uno will work fine, and the arduino code should compile and run just the same. We chose a nano because we wanted something small and easily concealed.<br> <br> JP1 and JP2 are two separate header pins (one for each side of the nano). The actual pin mappings are the labels on the wires from the pins to the other parts, e.g. NANO_A7 indicates that pin goes to pin A7 on the nano. You'll have to determine the pin layout if you use an Uno, but they should pretty much be named the same.<br> <br> Best of luck!
I like the idea. This is what I would do. I would use RGB LED strip. <br> <br>When it is very dark and it's pass 10PM (or your bedtime) I would light up in RED so it does not affect your pupil dilatation has much has white LED. I would even light up just the right brightness when you go to the bathroom at night. <br> <br>You could use a Real Time Clock (RTC) or light intensity to know those time. <br> <br>With the RTC you could even flash in RED when you are late in the morning. Let's say, it see movement 15min before you need to leave, it could give you a hint by letting you know that you are late (flash red). When it's bleu your not late, orange you are at your limit. <br> <br>When you get back from work, and open the door like the video, you could even light up in green saying that you got physical mail. <br> <br>there is a gazillion thing you can do. <br> <br>Thanks for sharing.
All really good ideas - our setup is very close to a desktop computer, so for the next version we were thinking of extending this with USB serial, at which point we could do all sorts of awesome time-based notifications without even needing an extra RTC module.<br> <br> Glad you like it!

About This Instructable

181,441views

1,479favorites

License:

More by FabricateIO:Home Automation with Amazon Echo voice control Cheap Arduino Controlled Light Sockets - Reverse Engineering RF Eye-Glowing Robotic Skull 
Add instructable to: