Having fun with electronics is something any engineer should find time to do. Even if the circuit has no practical use, it can still be a fun experience. Build it just because you want to...
Last Halloween I put several pairs of LED eyes in the plumeria bushes above the driveway. They immediately got attention, the bright red LED's give a surprisingly eerie effect for such a simple device. I had thought of doing these just a few days before Halloween. I like to dress up the area around my real activity for the evening, setting up a telescope in the driveway for the neighborhood trick-or-treat crowd to view.
The eyes looked pretty good, but I wondered if I could make them more interesting. Maybe triggering on light or sound and creating an impression of little creatures in the bushes? The whole idea was simple and yet fun. I just did not have the time to put it together, maybe next year.
That next year is now this year.
Design
The design is easy, a nice example of KISS, keep it simple s... The effect does not need any sophistication to work. Any complexity desired can be in the code.
Note- This design still needs a little work, but is getting close. The LED's and light triggering works fine, it is when making sound that the design needs finishing. If you want to build this now, you might need to fill in a few blanks on your own.
The circuit is built on a small piece of perfboard. The size is cut to easily secure to the side of a two AA cell battery holder. The black plastic of the battery holder is not easily seen in the dark
A small micro-controller (uC) provides the control. An early version of the circuit was built around a pair of operational amplifiers, this proved too limited for practical use, it could trigger on a change in light, but often failed under varying light conditions. The uC allows various rules for triggering to be implemented and the option for generating sound as well as light. While the op-amps worked, the uC version is a lot more fun.
A
PIC12C672 was used as it was appropriate for the design. I had a number of the older UVEPROM version on-hand from older projects to use for development. While I have no in-circuit debug capability for these eight pin devices, the code is simple enough that this was not a major handicap.
I had not used UV erasable EPROM in years, and yet here were a couple dozen parts carefully stored away for use one day. I was not even sure my UV eraser would even work. I could not find the power supply, but connecting a bench power supply produced a reassuring violet glow in the tube.
What did not work was my ancient PICSTART Plus programmer, it would simply not work through the USB serial adaptor after hours of trying. In it's place I ordered the
Olimex USB powered PICSTART compatible programmer from
SparkFun. This worked flawlessly to program the parts, with that and the UV eraser I was in business.
The schematic is quite simple, each of the devices (LED's, phototransistor, sounder) are simply connected to the appropriate uC pin.
The phototransistor is biased by a single 499kohm resistor. This seemed to give a nice range of resulting voltages in the low light levels expected during operation. Triggering is done using by detecting a change in illumination, not an absolute threshold, thus this should provide nice performance.
The LED's are turned on when the uC provides a high output. The PIC has a high output drive capability on all pins, eliminating the need for any buffering. A 499ohm resistor limits the current to about 2mA in each LED. The use of high brightness, efficient LED's gives good brightness at this low current.
Sound is provided with a miniature piezo sounder. The range of frequencies is limited only by the processor speed, in practice this can be up to 8kHz. The speaker is connected with a low pass filter and AC coupled to the uC drive pin.
Code
The code is, as always, a work in progress. There are hooks for things that might be added, other elements allow flexibility. The code may not be efficient, but can be easily modified to as I have fun changing the elements around. It is a single source file of absolute (non-relocatable) assembly code that will assemble directly in Microchip's MPLAB software.
With current code the eyes trigger with any small change in brightness. The threshold is programmable, and currently set quite low, the hope is that any small change, such as the wind moving the leaves and flickering the light from the streetlights will set it off. Or maybe just by sweeping a flashlight across the bushes. In the absence of any trigger the eyes will light every few minutes.
The first ten seconds of operation is test mode. In this mode the LED's will flicker once for every trigger event. With large changes of light there will be a series of flickers to allow the magnitude of the change to be seen. After test mode the device goes into idle, waiting for a trigger event. If there is no trigger for four minutes, the eyes will trigger as a timeout. The eyes will then light for ten seconds accompanied by a chittering sound. All of these duration are set as constants found at the start of the code and can be set in anywhere from 1 to 255 seconds.
Remaining Items
A few things still need to be done before building a few more and deploying the devices on Halloween...
- The small sounder I used is much too quiet for the final desired result. Three volts is just not enough to drive the device to an acceptable volume. This needs to be replaced with a piezo that can operate at a lower voltage.
- The sound needs to be tuned to create a better chirp, current code simply sounds a fixed frequency for a programmed time. A modulated sweep should do the job.
Effect
The effect is simple and dramatic. The bright LED's immediate attract attention of Halloween visitors to the yard. A simple set of two LED's is immediately recognized as a pair of red eyes staring out from the foliage. I can only hope that adding some activity will increase the effect. With the simple design I should be able to make half a dozen and create a flock of critters.
With the telescope and some red lights, kids run from across the street to see what is going on. Watching a child's eyes light up when seeing the Moon or Jupiter through the telescope for the first time is a great experience and makes the whole effort worthwhile.