This is a trivial little project to create the appearance of something carnivorous… lurking in the dark… with intent. Half a dozen of these in the bushes or windows gives some creepy background ambiance.make_halloweenbadgeV2 (1)

A very basic Atmel microprocessor, the ATTiny45, is programmed to make two LEDs slowly dim, brighten, and occasionally “blink” by turning the LEDs off and on. The blinking interval is pseudo random, controlled by an eight-bit linear feedback shift register (LFSR — see the Wikipedia article describing them. There’s a minimum blink time, so that the LEDs don’t turn off more often than every three seconds or so.

Brightness is controlled using the Pulse Width Modulation (PWM) facility of the ATTiny45. An interrupt is generated by an internal timer overflow about eight times a second. The interrupt handler sets a tick_flag and checks to see if it’s time to blink. If it is, it sets a blink_flag as well.

The main loop checks the flags, increases or decreases brightness on each tick by modifying a comparator register, and blinks each time the blink_flag is set. See the code file BE-45.c for details. BE-45.c and a Makefile are in the Girhub repository here:  https://github.com/BradBrand/BlinkingEyes

Blinking Eyes schematic

The Blinking Eyes schematic with an optional on-off switch.

The circuit is trivial. In addition to the programmed ATTiny45, there are two LEDs with their attendant resistors and a capacitor to smooth the power provided by a 2032 coin battery.

The links in the parts list are for examples only.  There are many cheaper options available, particularly on eBay.

To show the simplicity of the circuit, I wired up an example on a breadboard. It’s just the microprocessor, two resistors, two LEDs, and the capacitor (see the picture below). The resistors are connected to pins 5 and 6 on one side and to the positive (longer) leg of the LEDs on the other. The negative (shorter) leg of the LEDs is attached to ground.

Power is provided by a 2023 battery wired up throwie style; a capacitor connected to power and ground keeps the power clean. Two wires for power (pin 8) and ground (pin 4) supply the microprocessor, and assuming that it’s already programmed, this is all that’s needed.

The board is actually the most expensive component. Since I didn’t want custom-made boards in quantity, I decide to use the Evil Mad Scientist ATMegaXX8 target board. It’s relatively cheap in quantity, and there’s a good blog article about adapting various breakout boards for alternate processors.

Screen Shot 2013-10-17 at 3.32.52 PM

A breadboard version shows the simplicity of the circuit.

The board also makes adding a six-pin programming header very convenient which let me use my Adafruit USBTinyISP to program the microprocessor. Three wires are all that’s needed to turn it into the perfect ATTiny45 development board.

Below are the step-by-step instructions for creating a more permanent version that will better stand up to being cable-tied to the bushes.