Tag Archives: ATtiny45

Building some spook-tacular blink eyes with Adafruit and Atmel

Typical festive Halloween activities include trick-or-treating, attending costume parties, decorating home exteriors, carving pumpkins into jack-o’-lanterns, lighting bonfires, apple bobbing, visiting haunted attractions, playing pranks, telling scary stories and of course, watching horror films. We at Atmel would like to add one more item to the Wikipedia list above: building Halloween-themed Maker projects like Bill Blumenthal’s Spooky Blinky Eyes.

trinket_sippy-cups

According to Mike Barela, the original version of the project is built around an ATtiny45 MCU; however, Adafruit’s iteration employs the ATtiny85 based Trinket or GEMMA. Tasked with fading a pair of LED eyes that randomly blink, the Atmel powered platforms offer 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,” Barela explained in a recent Adafruit tutorial.

“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.”

As Barela notes, Adafruit’s version of the Halloween Blinky Eyes project adapts the original code for use on the faster ATTiny85 processor and Arduino integrated development environment (IDE). It also adds a Cadmium Sulfide (CdS) photocell to allow the eyes to activate only below a certain light level, helping to save battery power.

Other key project components include:

  • 3V Trinket (may be substituted by a GEMMA)
  • Cadmium Sulfide Photocell
  • Two LEDs 2 56 or 68 ohm resistors (100 ohm will work also but eyes will be a tad dimmer)
  • 1-1000 (1k) ohm resistor
  • Tiny Breadboard (or other suitable wiring surface)
  • 6V coin cell battery pack
  • Two CR2032 Batteries
  • A prop to put your circuit in

“The circuit is fairly straightforward and can be assembled well within an hour. Headers (included with Trinket) may be soldered to facilitate attachment to a breadboard or proto board. Other parts may be pressed into the breadboard. Ready-made hookup wire or cut to fit wires make the connections,” Barela continued.

trinket_IMG_2334

“The same circuit with GEMMA. The LEDs go to D0 and D1 with a 56 or 68 ohm resistor (100 ohms is fine also but they will be a bit dimmer). D1/A1 is hooked to the junction of the photocell and a 100 ohm (1K) resistor. If you wish to just rely on the power pack on/off switch, you can eliminate the photocell and 1K resistor. The battery pack works well with wearables, as it has a JST connector to plug directly into GEMMA, [along with] an on/off switch to save power when the circuit is not being used.”

Interested in learning more about the Halloween Blinky Eyes project above? Be sure to read Adafruit’s detailed tutorial here.

Building a Halloween knock box with an Atmel MCU

A Maker by the name of Kyle has constructed a “Halloween knock box” powered by Atmel’s versatile ATtiny45 (or 85) microcontroller. According to Kyle, the box is fairly easy to put together, as basic components include an MCU, a piezo element (amplifier) for the knock sensor and a motor to provide the knocking feedback.

“The motor I originally tried was a cheap 6v [unit] for $2 or $3. Unfortunately, it didn’t have enough torque to move the weighted end and it had several ‘dead’ spots where it wouldn’t engage,” Kyle explained in a recent blog post. “I had even taken careful measurements of the motor’s dimensions and transferred them to Sketch-Up where I created a motor mount and later printed it in ABS. In the end, I rummaged through my junk boxes and found a motor that seemed small enough to fit.”

To make the knocking sound, Kyle took a small section of 12 gauge wire (about 1.5″) and made two loops – one for the knocking end and the other to mount to the motor.

“I used a hammer to tap the loop end of the wire over the motor shaft and used some super strong double stick tape to adhere the motor to the box. I had problems with the motor not returning fast enough and the knocking sound being too quiet,” he continued. “To fix this I put a weight (in this case a bolt) on the end. This gave it more than enough momentum to move the box and allows the motor to return fast. To get rid of that annoying clunk sound when it returns to the resting position, I glued some foam to the back of the weight.”

As noted above, electronic components for the Atmel powered Halloween knock box include a driver for the motor (simple 2n2222 transistor with a protection diode) and an amplifier for the piezo element, the latter of which allows the circuit to detect quieter knocks.

“The amplifier consists of a NTE490 MOSFET which was measured to have a threshold voltage of 1.7v,” said Kyle. “[Meanwhile], the gate is biased at just under 1.7v by a series of 7 diodes and a 11MΩ current limiting resistor. The current is so small that the diodes don’t fully conduct and as such, only drop about 230mV each.”

Once Kyle was satisfied with the operation of the circuit, he drew up a quick board in DipTrace and laid out the board in just under 1.5″x1.0″, allowing it to neatly fit on the smaller side of the box. The board was subsequently etched and populated, with Kyle continuing to test the microcontroller on the breadboard.

“On the software side of things, the microcontroller sleeps while waiting for a knock to trigger an interrupt. Once triggered, TIMER1 begins counting. When the next knock occurs, the current TIMER1 value is recorded in an array and TIMER1 cleared for the next knock. This repeats until either TIMER1 overflows or the array is filled,” he added. “If the overflow event occurs, then the knock timed out and it begins repeating the pattern back with the motor. A special event occurs when either 13 or 20 knocks are registered. When the first occurs, the box plays the Addam’s Family theme song. When the latter occurs, then the box waits for 15 seconds, then randomly begins knocking at the box for 30 second.”

Interested in learning more about building an Atmel powered Halloween knock box? You can check out a detailed breakdown of Kyle’s project here.