I’ve been getting interested in playing with the attiny, in particular the attiny85 (8 pins!) and the slightly more practical attin84 (14 pins). So I built a very simple programmer that can program either of these and be easy to use while programming.
The attinys (attinies?) can’t be programmed directly from a serial port. Instead, you can use a “regular” Arduino running the ArduinoISP sketch (ISP meaning In-System Programmer). That sketch is included as one of the standard examples in the IDE.
There are wiring diagrams all over the internet on how to do this, but it’s really straight-forward: connect the three SPI pins SCLK, MISO, and MOSI to the relevant pins on the attiny and the programmer, and connect one more pin from pretty much any one on the programmer (the sketch uses pin 10) to the RESET pin of the attiny.
For my programmer, I had two things I wanted to achieve:
- No FTDI chip. This is silly, but I’ve had lots of issues with the FTDI drivers on my Mac. I often find that after disconnecting the Arduino from a USB port, the Arduino will no longer be recognized on that port until I reboot.
- Be able to program and run the sketch without having to move the chip between the programmer and the circuit.
I decided to make a programmer using an Adafruit Feather, which runs the ATmega32u4. The nice thing about this is that it directly connects to USB, no more FTDI chip. My initial version was built right on the little prototyping area they include on the “bare” Feather.
That worked fine for the cute little attiny85, but not for the ’84. I also learned that those round Swiss headers look great but aren’t very practical: most of my jumper wires have square ends that don’t fit very well into those round holes.
The second version is now built using a prototyping FeatherWing/shield. That has enough space to fit sockets for both types of microcontroller. Their pinouts are quite different, so sharing a single socket is not possible, unfortunately. They both just need the same four connections (plus power and Ground), though, so wiring isn’t terribly difficult. I’m also now using male headers to connect the pins to the board now, via female-to-male jumper wires.
This proto board is really nice to work with and well thought out. The pins along the top and bottom edge are each connected in pairs, so the headers from below are easily accessible as separate solder points (and there are power rails on the side). That does mean I have to cheat a bit though to fit all those headers for my attiny84 socket by leaving out the header pins that connect to the board below for about half the pins along the top edge (I could have cut all those traces too, but I was too lazy for that).
Since there was some space left, I also added a reset button and an activity LED.
Here’s what the underside of the wing/shield looks like. The attiny84 has an odd pinout with GND on the top left and Vcc on the bottom left, but that actually works out quite well in this case in combination with the rotated attiny85 socket (just be careful in circuits, you don’t want these to be mixed up). This picture also shows the missing header pins (the top of the board is in the front here).
The only thing I had to change in the ArduinoISP sketch were the pin assignments of the RESET pin and activity LED. I’ve found that the error LED never lights up, so I ignore that. And I use the little LED on the Feather base board as the heartbeat (also fairly unimportant, but since it’s there…).
#define RESET 21 // pin A3/21 for RESET
#define LED_HB 13 // heartbeat LED on the Feather
#define LED_ERR 8 // not connected
#define LED_PMODE 18 // blue activity LED on pin A0/18
The result is a neat little programmer that can program either of the two attiny micro controllers and easily connect to a breadboard.
To program the attiny, all I need to do is select the correct microcontroller in the Arduino IDE (after installing this amazing new ATTinyCore) and pick Arduino as ISP as the programmer. This fails a bit more often than directly programming an ATmega, but for the most part it’s pretty smooth.
This is hopefully the start to some more postings on here, because I’ve been working on a few little projects using the attiny – inspired by the fantastic Technoblogy. Plus a few more things involving packet radio and other stuff…