I got the cute little 8 pin Atmel AT Tiny85 working with the Arduino IDE by following steps and hints in this post and playing with a couple of different core libraries.
At under $3 each, this chip is a great way to provide a little programmable control for a project where an Arduino might be overkill. If you use the internal oscillator, you can get five or even six I/O pins. In addition to normal digital I/O, it provides up to 3 analog inputs and 2 PWM outputs. There are limitations (including no easy serial) but you can do a lot with it.
You can write and debug code on an Arduino, change pin definitions to fit the 8 pins on the Tiny, then download it to the little guy. There’s no bootloader, so you need some kind of programmer to get the code into the Tiny. Fortunately, the “Arduino ISP” sketch included with the Arduino development environment is just the programmer we need. A couple of wires connecting the Arduino to the Tiny (usually on a breadboard) and we’re ready to go. The details are in the post from hi-low tech above.
One detail not correctly stated on the HLT page is that for Duemilanove you need to block the Reset signal (carried in on the DTR pin in the serial interface from the IDE) to keep it from interfering with programming the Tiny. The 10uF cap from the Arduino Reset pin to ground prescribed for the Uno works fine.
While wires stuck into the female headers in the Arduino work fine, since I expect to use Tinys in a number of projects, I made a sort of mini-shield to make it easier to set up and to avoid the errors I’m sure to make. I also put the 10uF cap on the little board so there’s one fewer thing to remember. Labels for which wire goes to which Tiny pin keep me from having to look it up each time I use a Tiny.
I hope to share what I’ve learned in a class at Workshop 88 on using the Tiny 85 with Arduino. Since the boards are so small, I’ll just make some up and let the students solder the header pins and wires from the cable to the board and have a programming cable take-away.
Update 11/27/11: Since I’m going to be using this cable (and an Arduino) as a programmer for other projects including one with five Tiny4313s, I redid the board to be convenient to use a ribbon cable to the “standard” 6 pin ISP header on the Arduino. It looks like many of the AVR family do serial in-system programming via SPI – using MOSI, MISO, and SCK (and Gnd) – and using the Reset pin to put the device into serial programming mode. It’s usually handy to have +5V, so those are the 6 pins on the standard header. This cable should be useful for several AVR chips – including burning bootloaders to ATMega 328s for Arduinos!
The new mini shield is set up for comfortably hand-soldering a ribbon cable to it, with an insulation displacement female 2×3 connector on the other end. (Yeah, the one in the picture is a 2×5. It was midnight and that was all I had – sorry.) There’s even a cryptic legend showing which wires are MOSI, MISO, SCK, Reset, V+, and Ground (replacing the Tiny85 pin numbers).
I did a quick test with a modified Blink sketch and was able to program a second Arduino (without using its bootloader) from one with the shield/cable plugged on and Arduino ISP running. (There was initial confusion when the first/programmer Arduino’s LED blinked in addition to the second/target’s LED. But since SCK/PB5/Pin19/D13 is connected to the LED on all Arduinos, and since the programming cable connects SCK to SCK (as well as MISO to MISO and MOSI to MOSI), D13 on the second Arduino was driving the LED on _both_ Arduinos. D’oh!) Also, by modifying boards.txt based on this info, I was able to create a new “board” entry for Duemilanove using Arduino ISP.
Based on the Tiny2313 board profile that came with whatever core libs I’m using (I’ll figure out which ones Real Soon Now!) I should be able to create a 4313 profile with the larger memory sizes, the 16MHz crystals I’ll be using and set up to use Arduino ISP. With a little luck and if I can just keep from making any dumb layout mistakes putting that header on the 4313 boards, I should be able to program the 4313s!
I’ll post the Eagle files as soon as I can figure out how to use Github. Thanks for the suggestion, Dave!
Update 12/16/11: Just an update on usage of the cable and ArduinoISP: I had used the cable to burn the blink sketch into my “good” Duemilanove (leading to the success comment above), and it appeared to work fine. But the next time I tried to use that board, the IDE couldn’t talk to it – giving an avrdude out of sync error I really wish I’d captured. What I believe happened is that while it burned the code to the board, it overwrote the bootloader.
Since I had the cable and a spare Arduino (a Diavolino), I thought it would be easy enough to burn a new bootloader to my Duemilanove, presumably fixing it. I ran into problems I should have anticipated, but will help me remember for next time: I’d been using the Diavolino as an ISP (for some 4313s), but I wasn’t certain of its state, so I figured I’d just reburn the ArduinoISP sketch to it for good measure. That didn’t work – another avrdude out of sync error. Have I really blown the bootloader on both my Arduinos?
No. The Diavolino still had the cable mini-shield attached. That, of course, contains the 10uF cap that defeats the IDE’s resetting the board after a download, which interfered with downloading the ArduinoISP sketch. I removed the shield, and burned ArduinoISP with no problem. Then I put the shield back on, connected the other end of the cable to the Duemilanove, and burned the bootloader to it with no problem. After that I could talk to the Duemilanove from the IDE, which is what makes me think I overwrote the bootloader in the first place.
- Burning a sketch to an Arduino through the ICSP with the cable works, but will overwrite the bootloader. There’s probably a way to set a load offset to avoid that, but I don’t know what it is (at least not yet).
- Trying to burn a sketch (ArduinoISP, and presumably anything else) to a board with the cable/shield on it won’t work. Take the shield off first.