Motion Detector Box

The initial goal for this project was to build a project enclosure out of wood. I initially had no idea what project I would do with it. I designed the dimensions so that an Arduino could fit inside the box and allow for some space on top for a shield, some sensors and buttons. The project ended up as a motion detector lamp. Combined with a small python script running on a computer, it locks the computer when motion is detected. Of course, what the python script does when motion is detected is up to you, this is just a simple proof of concept.

Woodworking

The enclosure is made out of yellow birch and mahogany. The technique is a derivative of the band-saw box technique used to build small boxes out of a piece of solid wood. The first step is to make a solid block of wood by gluing several pieces together. I decided to sandwich a piece of yellow birch between two pieces of mahogany. Clamp the pieces together and let dry for about an hour.

Next, remove the clamps and square the block on a table-saw or using a jointer. Once the block is squared, cut the two side panels and carve the interior of the box on the band-saw. Make sure you leave enough material for the screws that will hold the side panels. Finally, put it all back together, sand all visible surfaces and apply the finish of your choice.

Tip: Make sure you drill some pilot holes when screwing the side panels to avoid splitting the wood.

Electronic

Your project box is now done, it’s now time to fill it with electronic gear. For my project I’ll use a motion detector, 6 neo-pixels, an LED and a push button. The motion detector sits on top of the box and the six neo-pixels will be equally spaced on two sides of the box.

This is the build of material you’ll need to build this simple project:

The motion detector is quite simple to use. You power it using the Vcc/Grnd of the Arduino board and when movement is detected it sets the signal pin to 1 (5v). You should then use the ReadDigital() function in your Arduino sketch to read the state. There are two potentiometers on the motion detector, one to set the sensibility of the detector and the other to set the delay the signal pin stays up when movement is detected.

The Neo-pixels are even easier to use. I’ll not go into many details since Adafruit provides tons of samples on their Learning System . All you have to know is that only one output pin is required to drive as many Neo-Pixels as you want.

The button input is monitored using an interrupt. I am using an interrupt because some of the lamp mode sequences are not listening for inputs while executing. The debounce is made in the interrupt callback function. Make sure to read the Arduino spec to know what pin of your board is associated with the interrupts you want to use. For the Leonardo board interrupt 1 is associated to the pin #2 of the board.

Finally, I added a 3mm LED to indicate that the lamp is powered on. Not really necessary since the product is a lamp. The LED is driven through a 1K resistor connected directly to the Vcc pin of the Arduino.

If you want to use the project sketch with no modification connect the devices to the following pins. Note that you can change the pins you use simply by updating the values in the Arduino sketch.

  • The IR receiver on pin #4
  • The Neo-Pixels data line on pin #3
  • The button on pin #2 (For the Leonardo board)
  • The power LED on the Vcc pin with a 1K resistor

That’s it … What I love about these little project is that I can use it as sandbox for other projects. I make sure the USB connector is accessible so I can reprogram the board whenever I want to.

You will find all the source code on my github account at: https://github.com/pchretien/motionbox

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top