This post show you how to program the ATtiny micro controller using the Arduino as a ISP and why use a ATtiny instead of the Arduino for your projects.
What is ATtiny?
The ATtiny is a series of micro-controllers, like the ATmega328 in Arduino UNO. There are many models of ATtiny, some common ones for example ATtiny85 (8 pins) and ATtiny4313 (20 pins). The only different between ATtiny and ATmega is the ATtiny is generally smaller (as the name suggests). Here is a post about how to program the ATtiny2313 and ATtiny4313 using Arduino.
In theory you can replace the Arduino with a ATtiny chip if your project requires only a few simple inputs and/or outputs. The ATtiny cost (only about $3) much less as physical space. However you will need an external hardware programmer to program the this chip. Many people might already own an Arduino and this would be perfect to turn an Arduino into a ATtiny programmer.
Programming ATtiny45, ATtiny85, ATtiny44 or ATtiny84
I found this tutorial very useful, but the following brief instruction worked for me. For a complete instruction go here.
- Download and install the latest Arduino software if you haven’t (note that 1.0.2 doesn’t work)
- Download ATtiny master.zip and Unzip it.
- Locate your Arduino sketchbook folder
- 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 this folder structure: Documents > Arduino > hardware > attiny that contains the file boards.txt and another folder called variants.
- Restart the Arduino development environment. You should see ATtiny entries in the Tools > Board menu.
Now connect the electronics. They explain the connection in detail here.
And finally we can try and upload a program, we will use the “blink” sketch as an example.
- Open the Blink sketch.
- Change the pin numbers from 13 to 0. (Note: the pin number on the ATtiny85 is different from Arduino)
- Select the appropriate ATtiny IC model from the Tools > Board menu
- Select “Arduino as ISP” from the Tools > Programmer menu.
- 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.