This tutorial show you how to program an ATtiny45 or ATtiny85 microcontroller using the Arduino software and hardware. The ATtiny45 and ATtiny85 are small (8-leg), cheap ($2-3) microcontrollers that are convenient for running simple programs.
Connect the Arduino to the ATtiny as follows:
- ATtiny85 Pin 8 – Arduino +5V
- ATtiny85 Pin 4 – Arduino Ground
- ATtiny85 Pin 1 – Arduino Pin 10
- ATtiny85 Pin 5 – Arduino Pin 11
- ATtiny85 Pin 6 – Arduino Pin 12
- ATtiny85 Pin 7 – Arduino Pin 13
- Electrolytic Capacitor 10uF GND – RST
- If you haven’t already, download the Arduino software, version 1.0.4 (1.0.3 and 1.0.1 should work too, but not 1.0.2). Install the Arduino software, following the instructions for Windowsor for Mac OS X.
- Download the ATiny master.zip file from the link below.
- Unzip the attiny master.zip file. It should contain an “attiny-master” folder that contains an “attiny” folder.
- Locate your Arduino sketchbook folder (you can find its location in the preferences dialog in the Arduino software)
- Create a new sub-folder called “hardware” in the sketchbook folder, if it doesn’t exist already.
- Copy the “attiny” folder (not the attiny-master folder) from the unzipped ATtiny master.zip to the “hardware” folder. You should end up with folder structure like Documents > Arduino > hardware > attiny that contains the file boards.txt and another folder calledvariants.
- Restart the Arduino development environment.
- You should see ATtiny entries in the Tools > Board menu.
Instructions and Code
Next, we can use the Arduino as an ISP to upload a program to the ATtiny:
- Open the Blink sketch from the examples menu.
- Change the pin numbers from 13 to 0.
- Select the appropriate item from the Tools > Board menu (leave the serial port set to that of your Arduino board).
- Select the appropriate item from the Tools > Programmer menu (e.g. “Arduino as ISP” if you’re using an Arduino board as the programmer, USBtinyISP for the USBtinyISP, FabISP, or TinyProgrammer, etc).
- Upload the sketch.
You should see “Done uploading.” in the Arduino software and no error messages. If you then connect an LED between pin 0 and ground, you should see it blink on and off. Note that you may need to disconnect the LED before uploading a new program.