DIY Pulsing LED Motion Sensor
Pimp Your Box of Chocolates with Arduino IDE and ATtiny13Difficulty: Beginner
Time Required: 2 hours
Designer: eLABZ aka Dmitriy Abaimov
The ATtiny13 is small enough to be hidden inside a box of chocolates to create a blinking twinkling LED pattern when someone touches the box and sets off the rolling ball tilt sensor. The project uses a very small number of components and requires only basic soldering skills.
Charlieplexing is used to drive up to 12 LEDs via 4 I/O pins of the ATtiny13. The original project and the software are based on 10 LEDs but it's easy to increase the number to 12. The ATtiny will go into power-down mode after every blinking cycle and battery life of several months can be expected from small batteries like LR44. The same can't be said for your chocolates.
Build your own Pulsing LED Motion SensorRequired Tools and Components:
Bright red LEDs
Silver Oxide Battery 1.55V
Rolling Ball Tilt Sensor
30 AWG wire
SPDT Slide Switch
16-Pin IC Socket
Soldering iron and solder
Hot glue gun/glue
Check out the blinking box of chocolates video here.
Step 1 - Prepare the LEDsSolder 8-12" leads of 30 AWG wire to each LED. You need approximately 8-12" for each LED because their locations will be picked at random, so the wire has to reach anywhere in the box. Cut the LEDs own leads to 1/8" (3mm). Make sure to mark one of the wires: polarity matters a great deal in Charliplexed LEDs.
Step 2 - Solder the resistors and the tilt switchMount and solder all components except for the ATtiny13 MCU onto the 16-pin IC socket. Mount the four current limiting 120Ω resistors on top of the IC socket and solder them to the socket. Mount the tilt switch and its pull-up resistor to the underside of the socket (see the picture)
Step 3 - Solder all circuit connectionsComplete the circuit by adding the I/O pin connections and soldering LEDs.
Be extra super careful soldering LEDs to make sure the polarity is correct. Troubleshooting and fixing such a small circuit is very difficult. Don't use too much solder for the first LEDs - each of the I/O pins will receive six LED leads, so use only a little solder to prevent build-up. When you're mounting the tilt switch (the gray cylinder at the top of the picture), bear in mind its final position in the box. For better battery life, it should always be in an OFF position when the box is resting on a level surface. So, it's better to have it leaned onto the OFF side. On the other hand, the closer the body of the tilt switch is to the level position, the more sensitive it is. If it's nearly perfectly level, just walking past the table with the box on it will set it off. Experiment with the best tilt switch position during this step and also when you mount it inside the box.
Step 4 - Program the ATtiny13 and insert it into the socketUse your favorite programming tools to burn the program into the MCU. I used AVRISP MKII programmer, but there's a wide variety of hardware available to do the task - from an Arduino running in a programming mode to various AVRISP clones and original programmer design, some of which Jameco sells. As far as the program to control the programmer, you can use avrdude, but because I used Arduino IDE for development, I've set it up to recognize ATtiny13 and program it. It is a rather lengthy topic, please read about it at: eLABZ.
The Arduino sketch we'll be compiling and burning is here: http://elabz.com/wp-content/uploads/2012/04/Charlieplexing_Tiny13_softPWM.ino_.zip
Please check out this page http://elabz.com/pimp-your-chocolates-with-arduino-ide-and-attiny13/ for tips on modifying the program, should you find the blinking pattern, speed or the number of LEDs in need of change.
Step 5 - Solder the battery and test everything on the benchSolder the battery to the corresponding pins of the IC socket and if you like, use the optional slide switch on the battery's positive lead. The goal of this step is to test everything before mounting in the chocolate box (or whatever enclosure you've chosen). Make sure everything works before you start wielding the hot glue gun!
Troubleshooting will become progressively more difficult after this point.
Step 6 - Glue the components in placeBe careful not to touch the hot gun to the plastic insert! It melts very easily.
Remove the plastic insert from the chocolate box, flip it over and use a hot glue gun to glue the components in place. Randomize the LED positions. There are plenty of ridges and valleys on the back of the plastic insert to mount all components. Sink the LEDs into *random* valleys and let the glue drop on them to hold them in place when set. The largest spaces are around the perimeter and this is where the larger components - battery and MCU circuit will go.