I’ve been in this situation many times: I just finished an Arduino project, I’m happy with it and would love to save it, but I only have 2 Arduino boards. Do I sacrifice one to keep this project intact or pull everything off the breadboard and move on? For all the Arduino enthusiasts that can relate to this, thankfully that’s not the only 2 choices.
In my last post I mentioned the Arduino-Tiny project that allows you to use ATtiny chips as an alternative to a full Arduino in projects. For smaller projects that only need a couple pins, this is a great solution. It’s pretty simple to do and in most cases you probably have everything you need to do it. To upload the Arduino code to an ATtiny you can use a dedicated hardware programmer or you can use an Arduino as an in-system programmer (ISP). Here is how the whole process works:
Components you’ll need:
- ATtiny chip (in this example I’m using an ATtiny85 but many others are supported)
- Arduino (Uno or Duemilanove)
- Jumper wires
- 10 uF Capacitor (only if using an Arduino Uno)
- 1 LED with resistor
- 3 LEDs of different colors with resistor (Optional)
UPDATE 5/28/2012: There was a bug in version 1.0 of the Arduino software that broke the ArduinoISP sketch. This bug has been fixed in version 1.0.1 of the Arduino software. Please upgrade before performing this step.
First we need to upload the ArduinoISP sketch so we can use the Arduino to program the ATtiny.
- Open up the Arduino software
- click File>Examples>ArduinoISP
- upload the sketch.
Next we have to setup the wiring to allow the Arduino to program the ATtiny.
Here is how the connections need to be made:
As stated above the LEDs are optional but can help if you run into issues. Here is what they mean:
Pin 9: Heartbeat – shows the programmer is running
Pin 8: Error – Lights up if something goes wrong
Pin 7: Programming – In communication with the slave
You are going to need to setup this wiring every time you want to upload code to an ATtiny chip so I would recommend setting up a breadboard dedicated for this purpose. I had a proto-shield lying around so I decided to use that. Here is a picture of my setup:
This guide assumes you have Arduino IDE version 1.0, to install support for programming ATtiny chips you need to:
- Download the latest Arduino Tiny code: http://code.google.com/p/arduino-tiny/downloads/list
- Create a “hardware” folder inside the Arduino Sketch folder
- Extract the zip file to the hardware folder you just created.
- Open Arduino and check the Tools>Board submenu. You should have ATtiny chips as options
Now you are ready to upload a test program to your ATtiny:
For a more complete reference for the pinouts of various ATtiny chips refer to: http://www.akafugu.jp/posts/resources/reference-sheet/
A good test here is to upload the Blink sketch.
- First hook up an LED to the D4 pin on the ATtiny
- Open File>Examples>Basics>Blink
- Change the sketch from using pin 13 to use pin 4
- Go to Tools>Board and select the ATtiny chip you are programming
- Go to Tools>Programmer and select “Arduino as ISP”
- Then click the Upload button
- Your LED should start blinking now
This is just a basic example but as you can see you have 6 usable pins on this little chip. If you want to expand the functionality of this there is also an I2C library that works on ATtiny chips and acts as a sender or receiver.