Arduino: Upload HEX Files to ATtiny85 Using Your Arduino and AVRdude

Use your Arduino UNO to upload a HEX file to an Atmel ATtiny85. In this tutorial, I am using Windows 7 64 bit.


You’ll need:

  • Arduino UNO (or something similar)
  • ATtiny85 (or similar Atmel target microprocessor
  • jumper wires
  • Arduino environment (latest release)
  • AVRdude (latest release)
  • a test HEX file (I used the TV-B-Gone hex file)

If you’re like me, you’ve spent countless hours with budget ISP programmers (like the AVR Pocket Programmer) and had little success uploading HEX files to the ATtiny85. Fortunately, if you own an Arduino, then you do not need another ISP. Turn your Arduino into an ISP by completing the following steps:
  1. Connect the board as usual for uploading code.
  2. Go to File  > Examples > ArduinoISP
  3. Upload this sketch to the Arduino
If you need to generate a HEX file in Arduino, you can do so by holding “Shift” and clicking “Verify”. If the sketch compiles correctly, the second to last line in the output will be the path name to the HEX file. For example, using the simple Blink program, the output should be something like:
Copy this location because you’ll need it later if you don’t already have a HEX file to upload.
Lastly, note the COM port used by the Arduino. My computer uses COM3. You will need this later.

Using a breadboard, make the following connections between the Arduino and the ATtiny85. Use the picture for reference. (Source). *Note the 10 microfarad cap between RESET and Gnd on the Arduino
  • ATtiny Pin 7 to Arduino Pin 13 (SCK)
  • ATtiny Pin 6 to Arduino Pin 12 (MISO)
  • ATtiny Pin 5 to Arduino Pin 11 (MOSI)
  • ATtiny Pin 1 to Arduino Pin10 (RESET)
  • ATtiny Pin 8 to Arduino +5v (Vcc)
  • ATtiny Pin 4 to Arduino GND (Ground)

So far so good, now time for AVRdude (assuming it’s already installed, if not, click here for instructions). Open the command prompt (Start >> type “CMD”, hit enter) . Navigate to the directory containing the HEX file by typing “cd” then the directory, like:
cd C:\users\folder_containing_HEX_file
Now that you are in the right directory, all that’s left is to blast the file into the ATtiny85. To do so, use the following command:

avrdude -P comport -b 19200 -c avrisp -p attiny85 -v -e -U flash:w:hexfilename.hex

, replacing comport with the proper comport (like COM3) and hexfilename with the proper name. Hit Enter, and if all the planets align, the code will be uploaded successfully. It may take a few seconds.

If you encounter any error messages, you may try disconnecting the Arduino UNO from your computer and reconnecting it. You can also try uploading the ArduinoISP sketch again.
Be sure to check out…
For a fun weekend build using the techniques in this post, check out the $3.50 TV B Gone clone by darksponge.
Closing Remarks
I came up with this method by combining two methods I read about. I haven’t been able to find a tutorial that explains this very clearly, so I hope this helps. Please read the sources for additional information on programming these devices.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s