Introduction: Automatic Hallway Runner Lights

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. 

Step 2: Program the Arduino

With your circuit fully built, it's time to give this project a brain..

We've attached the code we used for the Arduino. Note that it contains two parameters that you're free to customize to your needs and situation: LIGHT_THRESH (how light sensitive it is - increasing sensitivity means that it'll need to be darker to activate) and TIMEOUT (how long the lights remain on after detecting motion - increasing it will cause the lights to stay on for longer).

With VIN disconnected, upload this code to the Arduino. Open up the serial monitor and see what the values become in high and low lighting, then set your threshold to match. Make sure to test this as close as possible to where you're installing the sensors - lighting conditions can change drastically in the space of a few feet.

When you have a threshold you think works, disconnect your Arduino from your computer and connect it to the 12V supply. Your LED strip should now be light- and motion-sensitive! 

Here's the Arduino code we used:

// Automated Runner Lights (v1.0)
// Scott Martin & Todd Medema
// http://fabricate.io
// 10/3/2013
//
// Change this code to your heart's content!

// Constants won't change. They're used here to
// set pin numbers and thresholds:
const int motionPin = 6;// A6
const int lightAnalogPin = 7; // A7
const int ledPin = 3; // D3
const int LIGHT_THRESH = 1000;
const int MOTION_THRESH = 250;
const int TIMEOUT = 1000;

// variables will change:
int motionState = 0; // countdown after last motion
int lightState = 0; // countdown after last dark
int LEDActive = 0; // if LEDs are on
int LEDBrightness = 0; // current LED brightness (for fade in/out)

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  if (analogRead(motionPin) > MOTION_THRESH) {
    motionState = TIMEOUT;
  }

  if (analogRead(lightAnalogPin) < LIGHT_THRESH) { //Is Bright
    lightState = 0;
  } else {
    lightState = TIMEOUT;
  }
  if (motionState > 0) motionState -= 1;
  if (lightState > 0) lightState -= 1;

  Serial.print("cell: ");
  Serial.print(analogRead(lightAnalogPin));
  Serial.print(", pir: ");
  Serial.println(analogRead(motionPin));

  if (motionState && (lightState || LEDActive)) {    
    LEDActive = true;
  }
  else {
    LEDActive = false;
  }
  if (LEDActive) {
    if (LEDBrightness < 255) {
      LEDBrightness = min(LEDBrightness + 1, 255);
    }
  } else {
    if (LEDBrightness > 0) {
      LEDBrightness = max(LEDBrightness - 1, 0);
    }
  }
  analogWrite(ledPin, LEDBrightness);

  delay(10);
}

Step 3: Install the Lighting

So far, we've built the circuit and programmed the arduino with the proper lighting thresholds. Now it's time to mount your LED strips!

You'll want to put your LED strip about 6 inches above the floor. Masking tape works fine to hold it to the wall - though, if you won't be moving out any time soon, the strip does have an adhesive backing that you can use. The lights are bright enough that you only need them on one side of a hallway, but feel free to light both sides of the hall if you have extra.

You can cut the strip up into pretty small sections (cut along the marked cut line) and reconnect the sections with wires. This lets you skip past doors by running the wiring over the door frame and continuing the strip on the other side.

Once you have the lights attached to the wall, try connecting them directly to the power supply and making sure all sections light up properly. If you discover a bad segment, check the connections between strips to make sure they're unbroken. If nothing lights up, you might have a short circuit! Disconnect the lights quickly and test the lights with a multimeter to make sure power and ground are separate.

We noticed that, when uncovered, the light strips are really bright and irritating to look at. We can fix that! Grab some computer printer paper, and cut it into 1.5" wide strips. Fold these strips in 1/3rds back on each other (have the two folds go in opposite directions so that you end up with a Z shape).

Take these strips and, using masking tape, secure them directly above the LEDs. This obscures the LEDs from the top and side, making them much less harsh to look at and focusing their light on the ground, where you want it to be!

Step 4: Sensors Installation & Recalibration

Now that we have the lights in place, install your sensors.

Ideally, the photocell should be in a place that accurately reflects the lighting of the entire hall - we placed ours close to the ceiling in the middle of the hallway. The PIR sensor should be placed in a location with a full view of the hallway, and an obstructed view of everywhere else. You might want to use paper or some other material to block a part of the sensor and prevent false lighting from people that walk near where you're trying to light.

After the mounting is finished, re-check your thresholds by following Step 2 in the instructable again. The values will probably have changed slightly. 

Step 5: Conclusion

Congratulations! You should now have some incredibly cool and functional runner lights along your hallway, letting you roam at night without bumping into things or disturbing your roommates!

As always, let us know in the comments if you have any questions or ideas for improvements. And we'd love to hear from you if you install a set of your own!

Did you like this Instructable? Don't forget to Favorite it and Follow us on Facebook!

Hardware Hacking

Participated in the
Hardware Hacking

Microcontroller Contest

Participated in the
Microcontroller Contest

Workshop Contest

Participated in the
Workshop Contest

Make It Glow Contest

Participated in the
Make It Glow Contest