Microcontrollers are, without a doubt, amazing little things. They are versatile, powerful, and extremely tiny. Unfortunately, the latter trait is also shared by both my wallet and my programming skills. My understanding of C is poor, and I can hardly afford to buy something like an Arduino or a decent ISP. And in any case, the Arduino would be overkill for many of my projects, which only need simple IC's.

     But as many of you know, DIY always finds a way. This tutorial is meant for those among us with no budgets or programming experience who want to start using these little machines. It is not based around the ATmega328 (the Arduino Uno chip), but rather the Attiny line of chips (the Atiny85 and Attiny2313, to be specific). The total cost of this project can go as lower than $15 if you know where to buy from, and you can still use the original Arduino IDE and language to program your projects in the end. Keep in mind that you will need some soldering skills to get this project done.

Step 1: So What Programmer Do I Get?

My, my, I thought you'd never ask. There's a large number to choose from, so I'll give you a rundown of the most popular ones.

• The USBasp is quite possibly the cheapest programmer out there, but you should be careful when buying them; some versions use outdated firmware or are missing jumpers. Make sure that your model has three jumpers (or three pairs of holes with J1, J2, and J3 printed next to them). You can find them on eBay starting at only $3. Be wary of the shipping times that the Chinese ones come with.

• A parallel port programmer is around the same price and can even be made at home. It, obviously, will only work on computers with a parallel port. 

• The USBTinyISP is a step up from the USBasp. It costs $22 from Ladyada, but knockoffs can be had from eBay for around $12. Keep in mind that it cannot program certain high end Atmega devices due to memory limitations.

• The AVRISP mk.II is Atmel's official programmer for the AVR line of chips. It is without a doubt the most powerful of these programmers and can be used with AVR Studio (complete with debugger!), but costs around $35 to get.

Your programmer might come with either a 10 pin connector or a 6 pin connector. The only difference between the two is that the 10 pin connector has 4 redundant/unused pins.

Due to my aforementioned lack of money, my programmer was a USBasp. Once again, make sure you get one with all three jumpers; mine looks nice and comes with a fancy case, but is missing 2 of them. Thankfully, it still works.

Step 2: Is That All?

Unless you plan on programming air, you might want to get a microcontroller and some parts for a programming cradle. 
Most AVR microcontrollers will work with the programmers I listed on the previous step, but only some can be used with the Arduino language. 
• The Attiny85 and Attiny45 are tiny 8 pin chips with 6 functional inputs and outputs with a max of 8kb of memory.
• The Attiny84 and Attiny44 are 14 pin clones of the chips above.
• The Attiny2313 is a 20 pin chip with 2kb of memory.
• The Atmega328 is the chip used on the actual Arduino. You'll have to edit a few things if you want to use it without its crystal.
Take your pick; any of these will work well.

In addition to a chip, you'll want a few parts to make a cradle; otherwise, you'll have to breadboard out all of the connections whenever you want to program anything. For that, you'll need:
• A chip socket (pick one that'll accommodate the chip you plan on using).
• Male pin headers, 2 sets of 5 (if your programmer has a 6 pin cable, go for 2 sets of 3.
• Female pin headers (same number of pins at your socket) OR more male pin headers if you want it to plug into a breadboard.
• Strip board.
• Wire.
• Basic soldering equipment.

If you want to get these fast, try Digikey. If you want to get these parts cheap with 2 week shipping, go with Tayda Electronics.

Step 3: Small Scale MIG Welding, Anyone?

To start out, lets assemble a simple (ghetto) cradle for our chips. Most of these chips have pinouts that differ quite a bit, so only the Attiny85 and Attiny2313 can be programmed on the same socket. The design I used for mine takes advantage of this.

First, arrange your parts on the stripboard as shown and solder them down. Try not to make your joints as ugly as mine.
Our goal is to match up all six essential pins on our programmer with the corresponding pins on our microcontroller; these pins would be MISO , MOSI , SCK , RESET/RST, GND , and VCC/VTG. The two rows of male headers will be where our programmer plugs in. I've included diagrams for most of the chips you can use. I've also included a diagram that shows which pin is which on your header. Go slow, and make sure that you don't mix up any pins. 

Once you are done, test out your pins with a continuity tester and make sure that they all go to the right places. You may want to seal up your circuit to prevent damage. In my case, I just drenched it in hot glue. Thankfully, FCC regulations do not apply to my circuit.

Step 4: Setting Up Your Not-so-micro Computer.

Now that our chip is ready to be programmed, we need to set up the programmer. If you have a USBasp and run windows, download the driver from http://www.fischl.de/usbasp/ and install it. If you have a USBtinyISP and run windows, get your driver from http://learn.adafruit.com/usbtinyisp/download. Check in "Device Manager" to see if your programmer shows up when you plug it in; if so, you are ready!

Download the latest version of the Arduino IDE from http://arduino.cc/en/Main/Software and install it. To get this to work with chips other than the ATmega328, we'll need to add a few plugins. Go to https://code.google.com/p/arduino-tiny/ and download the latest zip of Arduino-tiny. Go to "C:/(Your install directory)/Arduino/hardware" and create a new folder called "tiny". Unzip the contents of arduino-tiny into this folder, and rename the file called "Prospective Boards.txt" to "boards.txt".

Then, open up the Arduino IDE. First, go to Tools->Programmer and select your programmer from the drop down list. Then, go to Tools->Boards and select the chip that you want to program. There might be multiple versions of the same chip; make sure that you select the "1 MHz" version, as factory chips are tuned to run at that frequency out of the box. 

If you are using a USBasp, you should short out Jumper3. This slows down the programming speed enough for you to program chips that work at 1 MHz.

Finally, give your new chip a whirl! Find "Fade" in the File->Examples->01-Basics menu and change the line
int led = 9;           // the pin that the LED is attached to
int led = 1;           // the pin that the LED is attached to
since your chip may not have a pin 9. Then, hit upload.

You might get a few warnings, bu if everything works out...you should have successfully programmed your first chip!
Hook up the GND pin of your chip to the negative terminal of a 5v supply and VCC to the positive. Then connect an LED (with a resistor) between the negative terminal and pin 1 of your chip. If it slowly fades in and out, you win!

Step 5: Get Programming!

Check out the Arduino website for more examples and tutorials; it's an easy language to learn. Keep in mind that some commands and libraries might not work or take a bit more effort to get working.
Here are a few last tips to remember for the ride:
• If you want to make your device run at 8MHz, select the "8MHz" version of your chip and hit "Burn Bootloader". Keep in mind that most speeds higher than that will need an external oscillator.
• If you want a bigger programming challenge, learn to code with AVR Studio. You'll have to manually use AVRdude to actually burn the code onto the chip, but you will have MUCH more control over how your program works.
• If you plan on programming a fresh Atmega328 (Arduino Uno chip) with this setup, you (ironically) can't directly use the Arduino IDE to do so. I've yet to try this, but you should be able to fix this with the following. You'll have to edit the boards.txt in  "Arduino/hardware/arduino" and change a few lines in the "Arduino Uno" section. Replace the lines


and change

That'd be it! With a day's work and nothing but cheap parts from China, you've just built a (hopefully) functioning programmer.
If you see any mistakes in my ible or have any questions, leave a comment. Good luck.
<p>Is think my USBasp is out of date! :O</p><p>I tried using Arduino IDE and avrdude but I get the same error again and again:</p><p>avrdude -p t85 -c usbasp</p><p>avrdude: warning: cannot set sck period. please check for usbasp firmware update.</p><p>avrdude: error: programm enable: target doesn't answer. 1 </p><p>avrdude: initialization failed, rc=-1</p><p> Double check connections and try again, or use -F to override</p><p> this check.</p><p>Then when I do override using -F this happens:</p><p>avrdude -p t85 -c usbasp -F</p><p>avrdude: warning: cannot set sck period. please check for usbasp firmware update.</p><p>avrdude: error: programm enable: target doesn't answer. 1 </p><p>avrdude: initialization failed, rc=-1</p><p>avrdude: AVR device initialized and ready to accept instructions</p><p>avrdude: Device signature = 0x000000 (retrying)</p><p>avrdude: Device signature = 0x000000 (retrying)</p><p>avrdude: Device signature = 0x000000</p><p>avrdude: Yikes! Invalid device signature.</p><p>avrdude: Expected signature for ATtiny85 is 1E 93 0B</p><p>avrdude done. Thank you.</p><p>I am trying to program ATtiny85 on a breadboard.</p>
<p>I know it's a while since you posted but I've had exactly the same issues today - others may have the same. Here is a write up of my experience:<br><br>http://www.noobtronics.com/dodgy-usbasp-atmel-avr-programmer-from-banggood/</p>
<p>&quot;avrdude: warning: cannot set sck period. please check for usbasp firmware update.&quot;<br>- this is only about firmware for your usbasp, it's not important at all, you can live well with this! :)<br>&quot;avrdude: error: programm enable: target doesn't answer. 1<br>avrdude: initialization failed, rc=-1<br>Double check connections and try again, or use -F to override this check.&quot;<br>- this IS your real problem: avrdude don't detect an mcu, -1 error is an hardware error code, meaning any of:<br>- no mcu at all<br>- mcu is working with another clock, or you disabled reset pin mai function, so, usbasp cannot detect the mcu. to solve this thing, you need an HV rescuer... search here, dmjlambert put a nice instructable on this subject.<br>- mcu is connected to the wrong pins<br>- usbasp connection cable is broken<br>- mcu dont get his 5 (or 3.3) V to work<br>- you fried the mcu! :)</p>
<h1>Not Found</h1><p>The requested document was not found on this server.</p><hr><br>Web Server at noobtronics.com<br>
<p>Your write-up has been deleted. )-: I was looking forward to reading it.</p><p>Would you re-post it on a more friendly web site and give everyone the new URL ?</p>
<p>Nice writeup! </p>
<p>Thanks - planning on doing at lot more on there in the coming weeks - got soooo much stuff to look at!</p>
<p>While you say that you have no skill programming in C/C++, you should be aware that when using the Arduino IDE, you are in fact using C/C++. There is *no* &quot;Arduino Language.&quot; It *is* C/C++. The only difference is that there is some behind the scenes linking and setup that is done for you. In the IDE you never see the &quot;main()&quot; routine that exists in all C/C++ programs.</p>
<p>That's not quite true ! The Arduino IDE's C++ macros are, in fact, a unique language in itself. They conveniently remove the intricacy of specifying the ports and DDRs that are necessary. All the programmer needs to know is the Arduino-given pin number in order to read from or write to it.</p>
<p>well, I am sure that arduino &quot;language&quot; has its own set of macros, but they are still written in c(C++). There is no arduino programming language. </p>
What you say is correct, but this is the case for almost every implementation of C/C++. There are always platform dependent macros that allow certain kinds of &quot;shortcuts&quot; to make certain functions easier. The core language is C/C++ with the ability to make structs, classes, pointers, reference variables, and every other kind of OOP constructs.
<p>do any of these programmers you've mentioned allow for high voltage programming (i.e. unbricking attiny85's)</p>
Hi I have USBasp with atmega avr 16&amp;or 32 dev board from eBay and want to get my programmer recognised in Avrdude.exe command prompt program and burn chips with it ? please help newbie....the photos depict what I have.
Hi I have a usbasp connector with avr atmega atmel 16&amp; or 32 programmer unit and need help in winavr command prompt finding and using my programmer that I bought of eBay in that program?
<p>I already had a USBasp programmer lying around, so your instructable was the perfect excuse to get started toying around with those awesome attiny85 chips. Inspired by your non-FCC compliant use of hot glue, I applied it generously to cover up my terrible soldering skills. I also printed a diagram with the pin numbers and attached it to the bottom.</p><p>Works flawlessly, and as GandaU below, I do get the same avrdude warnings which can simply be ignored.</p><p>Thanks!</p>
<p>Despite some warnings from arduino 1.6.4 s/w it work</p><p>Build options changed, rebuilding all Sketch uses 784 bytes (19%) of program storage space. Maximum is 4,096 bytes.</p><p>Global variables use 9 bytes of dynamic memory.</p><p>avrdude: warning: cannot set sck period. please check for usbasp firmware update.</p><p>avrdude: warning: cannot set sck period. please check for usbasp firmware update</p>
<p>blink works from arduino. usbasp + attiny45 + arduino + blink (change pin 13 to 3 like in hi-low tech) </p>
<p>Good morning. I am having problems and troubleshooting.<br>1. Orientation of the programmer Pins.<br>Mine has 10 pins. Viewing the pins from female side cable red strip on the top. Would VTG be on the Left or Right column of ;pins?<br>2. I have seen some instructions that say to modify the board.text in the hardware folder to comment out the particular chip you are programming. In my case the ATTINY85, Not sure if this is necessary or required. <br>Thank you in advance.<br>Charlie</p>
<p>Yes. Good instructable.</p>
<p>There is also another good tutorial titled:</p><p><strong>Arduino Uno R3 as a true ISP programmer for any Attiny and Atmega AVR</strong></p><p>see:</p><ul> <br><li><a href="http://forum.arduino.cc/index.php?topic=317138.0" rel="nofollow">http://forum.arduino.cc/index.php?topic=317138.0</a><li><a href="https://app.box.com/s/ol1z8jjnrpy6wly4w61imt7wcbxk3fcg" rel="nofollow">https://app.box.com/s/ol1z8jjnrpy6wly4w61imt7wcbxk3fcg</a></ul>
<p>Excellent tutorial, worked great for me (on OS X 10.7). I used a (cheap chinese) ZIF-socket for ease of use.</p><p>One small point, though: if you change the led pin in the Fade sketch to 1 as stated above, the led on physical pin 6 will blink (instead of pin 5 on the photo). Change the led value to 0 to make the setup in the photo work.</p>
<p>Great tutorial! Sorry in advance for the newb question. I can't select a com portーit's just grayed out in the Arduino IDE under tools. Is the USBasp supposed to create one? </p>
<p>Thanks, it was very helpfull.</p>
<p>Those &quot;redundant / unused&quot; pins on the 10 pin connector are Ground.</p><p>Their purpose is to prevent crosstalk between lines, as all the signals are separated by a ground line in the flat ribbon cable that goes between the programmer and the device. This allows you to have much longer cables without the worry of data corruption die to crosstalk in the lines. </p>
<p>Interesting, I didn't know that. </p>
<p>Thank you so much! This tutorial helped me out a lot. The only problem I had was figuring out that the pin numbers in the code aren't the same as the pins on the attiny. I figured it out though. Thanks again for the awesome tutorial.</p>
<p>Glad to have helped!</p>
<p>Great tutorial \m/</p>
Can you program an atmega8 with this set up ore do you need to change some lines aswell like the atmega328?
Nice, I will try this one.
I get those errors with my USBASP as well. I am confident mine isn't out of date, it is possible how the program is written to work with Arduino that makes it throw that error. <br>Mine also has no problem with programming even with the errors.
Did you set the slow speed jumper on your USBASP (or does it exist?)? Keep in mind that the arduino-tiny only effects how the code is compiled; the uploading of the program is still handled unchanged by AVRDUDE.
Nope no jumper and thanks for the correction.
Great guide. Regarding usbtinyisp programmer, are you sure usbtinyisp is the original &quot;creator&quot;? I thought this http://dicks.home.xs4all.nl/avr/usbtiny/ exists 1st and deserves a mention. AAMOF the ladyada page acknowledge that &quot;code and design&quot; are based off Dick's works. <br>The msp430 is more fun to play w/. <br>
This entire instructable was actually made after my failthful MSP430 died for some reason.
lol gonna program intel i7 xD

About This Instructable




Bio: I am a highschooler who has an unhealthy obsession with the unusual and the esotoric. DIY seems to fit in perfectly with this.
More by Shagglepuff:Build a Low-cost Portable Wii Laptop The Idiot's Guide to Programming AVR's on the Cheap (with the Arduino IDE!) 
Add instructable to: