The short story: This week I made a blinky-buzzy toy to occupy our cat with a random sequence of teases. And he loved it!
The longer story starts just over a year ago, when Team Blinky friend Liza Stark gave me an 8-legged computer chip the size of a peanut and said, with wide eyes, “You can do amazing things with these!”
So for #MakeEveryWeek No. 3, I learned how to play with this minuscule computer.
The little chip was an ATtiny (pronounced like an author, A. T. Tiny), which is essentially a super-simple Arduino.
Its legs correspond to a some of the familiar Arduino pins: power, ground and five input-output points. More details are on the Sparkfun site.
Just like an Ardunio, you can code it to light LEDs, read simple sensors and buzz buzzers. You program it using Arduino desktop software and the Arduino language. You even use an Arduino as a kind of “mother ship” to load programs into the ATtiny — because it's missing all of the connectors Arduino boards have.
Mother ship, baby chip
To give the little chip a spin, I decided to load it up with a “blink” program and happily flash an LED.
To get programs onto an ATtiny, you need to wire it to an Arduino (or use a special board, which I don't have). This wasn't hard, but took several steps. Here's what I did:
- Made a folder on my computer called
hardwareinside the folder where I keep my Ardiono sketches.
- Downloaded the
ATtiny-master.zipfile from Github.
- Put the
attinyfolder inside that
- Hooked an Arduino Uno to my computer with a USB cable and started the Arduino software.
- Picked my regular “Tools > Board” and “Tools > Serial Port” settings.
- Loaded the Arduino with the mother-ship sketch from “File > Examples > ArduinoISP. ”
- Wired the Arduino to the ATtiny on a breadboard, as shown in the diagram on this page. (I happened to have a 100uf capacitor, instead of the 10uf, and it worked. Some sites say you might not need a capacitor at all.)
- Changed the settings to “Tools > Board > ATtiny45 (internal 1 MHz clock)” and “Tools > Programmer > Arduino as ISP”
I then added the LED and a 330k-ohm resistor as shown here. Then I opened the example blink sketch from “File > Examples > Basics > Blink.”
The chip doesn't have a Pin 13 so I changed that to Pin 0:
int led = 0;
Next, I uploaded the sketch and the LED blinked! “Hello world,” the little one says.
In my diabolical plan to entertain the cat, I put red LEDs on pins 0 and 1, and a little vibrating buzzer on pin 4 (next to the ground).
I then modified the blink program to randomly choose between blinking, buzzing and staying silent. It also randomly picks the number of times to repeat the thing it chose to do. The finished program is here.
Once I got it working on the breadboard, I used wire cutters to chop up a prototyping board until it fit snugly into the dome of one of those containers you get with a toy-dispenser toy. (You know, at the door of the grocery store? Those.)
Then I soldered the parts onto the board, just as they were on the breadboard, and added some female headers along the sides of the chip so I could link it to the Arduino again if I wanted to update the program.
I hot-glued a battery holder to the underside, wiring the [+] side to the chip's power (by way of an on-off switch) and the [-] side to ground.
Slid in a 3v coin battery, flipped the switch, snapped the dome to its base and gave it to the cat.
All of the above was brand new for me, which is pretty fantastic. I like how my Arduino experiments made it easier to adapt to this new chip. I'm already dreaming up more tiny projects.
I love the constrains of the chip's memory. The one I'm using has 4K. Four-thousand bytes is nothing. The words in this blog post, as plain text, are 4K. How sophisticated might I make such a tiny program?
Doing it again, I'd use a different buzzer. The vibrating-pager version wasn't quite buzzy enough.
Shoulda put the switch on the underside of the circuit board, so I don't have to take the board out of the come to turn on (it was late).
Really digging this #MakeEveryWeek commitment.