A recent MAKE project, Spooky Blinky Eyes by Bill Blumenthal, demonstrates an ATTiny45 processor fading a pair of LED eyes that randomly blink, giving a more realistic effect than standard "always on" LED eyes.
The effect is due to come clever programming of the timers available on the ATTiny processors featured on the Adafruit Trinket and Gemma microcontrollers. Pins 0 and 1 are capable of pulse width modulation. The timers are set to fade the pins in and out by changing the pulse width back and forth. The blink effect is using an algorithm called a linear feedback shift register (LFSR) to pseudo-randomly turn the eyes off and on quickly.
This project adapts the original code for use on the faster ATTiny85 processor and for the Arduino integrated development environment (IDE). It also adds a Cadmium Sulfide (CdS) photocell to allow the eyes to come on only below a certain light level. During sunlight, this will save battery power.
Parts List
- Adafruit Gemma M0, Trinket M0, Trinket Mini or Gemma v2 microcontroller board (if Trinket, either the 3.3V or 5Vtype works). We recommend using the Trinket M0.
- Cadmium Sulfide Photocell
- 2 LEDs (I used two 5 mm red for the evil look, you can use any size or color)
- (1k) ohm resistor
- Tiny Breadboard (or other suitable wiring surface)
- 6 volt coin cell battery pack
- 2 CR2032 Batteries
- A prop to put your circuit in
Text editor powered by tinymce.