Ghetto Programming: Getting started with AVR microprocessors on the cheap.


Microprocessors are so cheap these days. If only there were a way to program them up just as cheaply...

*wavy dream-sequence lines*

In this instructable, find out how to build up a complete AVR microprocessor toolchain: compiler, programmer software, programmer hardware, and some simple demos to get your feet wet.

From there, it's just a hop, skip, and a jump to world domination.

The endpoint is not quite as swanky as Atmel's suite, but it's gonna run you about $150 less and take only a little more work to get it set up.

This instructable is based on the Atmel ATtiny 2313 chip, mostly because it's one of the smaller chips (in size) while still being beefy enough to do most anything. And at $3 a pop (non-bulk), they don't break the bank.

That said, most of the steps are applicable across the AVR family, so you'll be able to re-use most everything when your programming needs outgrow the ATtiny and you reach for the $8-$12 ATmegas.

Update Aug 24, 2007: I've gone USB! It's neither ghetto nor particularly deluxe, but a nice middle ground. If you've got a computer without a parallel port, check this out.

If you've got a parallel port, or are just feeling cheap, read on!

Remove these adsRemove these ads by Signing Up
can you please put a schmatic
The Real Elliot (author)  minecraftpotato5 months ago
I _could_. But then you'd only know how to hook up one particular chip out of the whole AVR family. What you really need to know is that the pin on the programmer labelled MOSI connects to the pin on the chip labelled MOSI, etc. And then that works for _every_ chip.

But I'll see if I can whip up something helpful and graphic.

s005002 years ago
Can you please post a makefile for mac?
crjeea2 years ago
seeing thoughs LED's with resistors soldered to them I was just thinking wouldn't it be lovely if they were sold like that (:
An LED with presoldered 1K resistor... or even a resistor built in to the LED it's self... extra just an idea
Eirinn crjeea2 years ago
Well... depending on the voltage you supply to the LED you'll need different resistors. That's why they don't come integrated with a resistor :)
crjeea Eirinn2 years ago
Maybe a kind of zena LED might be a more useful idea.
I have seen LED's that can flash, think I would also like to see LED's that have pwm built in based on voltage so they can be dimmed with only two pins. Or maybe tri colour LED's that cycle through thier colours according to voltage.
kbchiew2 years ago
Thank you. Abit confusing here.
In the picture above, you shown PIN1= Reset.
In the listing, PIN1= SCK. PIN11 = Reset.
twenglish14 years ago
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x12 != 0x00
avrdude: verification error; content mismatch

avrdude done.  Thank you.

has anyone else had this problem?

See the registry update I posted in the comments...
Thanks for the help, but I am now using a USB programmer. I haven't had any problems yet
The Real Elliot (author)  twenglish14 years ago
I should make up an Instructable on what all the errors mean...

Verification errors mean that the chip didn't get the data right.  Check for loose connections here or there.

Also double-check the power supply that you're using for the chip.  The chips draw power in a spikey, unpredictable way, and that sometimes can cause trouble.  A simple solution that often works for me is to put a buffer capacitor across the AVR's power pins.  That is, take a capacitor of moderate size (0.1uF to 10uF?) and connect the positive end of the cap to the AVR's VCC pin and the negative end of the cap to the AVR's GND pin.

The capacitor acts as a little rechargeable battery, smoothing out the AVR's power demands. 

(Real engineers almost always start out with a buffer capacitor in their designs for reliability.  I omitted one here b/c I'm cheap and I can usually get away with it.  But you should try adding it if things go wrong.)

thanks, i will try that, but its weird the power supply i am using was working fine before? any idea why all of a sudden?
i tried adding the capacitor and i am still getting the same error, and all the connections are good
 Erase the chip before programming... Should do it.
If you use the parallel programmer under Windows XP be sure to use the below registry hack to prevent windows from interruping your programming signals.


Paste the above into Notepad and saveas dapa.reg
then right click MERGE intos registy. Will save you lots of problems with using parallel ports under windows with AVRDUDE for instance.
please define your pin outs in the pictures and define better in board thks
The Real Elliot (author)  fostersfriend2 years ago
How do you mean "better"? Is there something specific I can write that'd help?
Just label all the out puts on all the pictures
robot13982 years ago
can you tell how did you connect it to the 8 pin socket
jld12 years ago
I've downloaded the WinAVR just to try to play with C/C++. I don't have any uC right now but I plan to. I wrote a simple program using Programer's Notepad in C. I can't seem to compile the program? Please advise.

matstermind2 years ago
would you happen to have a schematic of parallel port pins to microcontroller? i find your current explanation a it confusing.
shanakaplus3 years ago
um looking for elevator avr program. Do you have example program ?
lpciprian3 years ago
OMG, I tried to make this for two weeks. I finally did it! I must say that my first mistake was that I didn't use an external source for Vcc. Second: I used a too long paraller cable. After I used a power source from one of my USB's and cutting my dapa cable to about 18 cm long (it was about 1,2 meters) I finally got a succesfull firmware flashing on my attiny2313...whew! Thank you The Real Elliot for your instructable!
What does this mean?

"A Direct AVR Parallel Access, or DAPA cable, is an incredibly simple and cheap programming method. You can build one very quickly for a few bucks worth of parts, but the convenience comes with a few gotchas. The first is that you must have a parallel port on your computer; something that modern laptop and some modern desktops don’t have. But if you’ve got an old PC around that has one this will get you up and programming in no time.

In fact, the first AVR prototyping I did was with one of these cables. That is, until I discovered another gotcha. This will only program low-speed chips. If you try to run the chip’s clock at full speed (by changing fuse settings… more in Part 3) you won’t be able to use a DAPA cable to talk to it any longer. There’s also the possibility of damaging your parallel port or worse if you do something wrong. But if you want to go for it anyway, here’s how I built mine"

I got this info from here:
Does this mean that if i modify the speed of the internal oscillator at the first programming, the programmer won't program the chip anymore?
beehard443 years ago
i head you can burn a bootup code on an ATmega and use it as a standalone arduino
The Real Elliot (author)  beehard443 years ago
Very true. An Arduino is really just an AVR with some of the pins dedicated and a bootloader and some timing routines pre-configured for you in the firmware.

Only some of the AVR chips have bootloader capability, though, so you should check the datasheet to make sure. I know the Mega88 does, for instance, but the M48 doesn't.

The Tiny2313 does bootload, but you'll want to use a small bootloader like this one:
It's pretty hard to fry them. I bet the chip is fine. Anyway, I learnt much from your essay. And I think that some IC components can be find on ChinaICMart.
Funnymonk3 years ago
Hello I think I've followed all of your instructions to the letter but there is no Make prgram button in tools for me. How do I fix this?
bha1234 years ago
 guys where can i find these micro controller and ics actually i am IT student but for my project i need them can any body suggest where can i get them

is this parralell connector work for picaxe to connect it with pc
cdousley3 years ago
will this program attiny13
The Real Elliot (author)  cdousley3 years ago
Yup.  You just need to hook up the six programming lines to the right pins.  See the datasheet for where to route them.

Thanks for the help all i need now is the ic socket
elbriga3 years ago

I think I just 'fried' 2 attiny2313 :(

The only thing not quite equal from your instructable is that my led has the resistor (330r) on the + pin of the led, so i connected the ground pin of the led to ground and the other + resistor to PD4, then the avrdude stoped working, not recognizing the chip anymore...

What could have 'fried' my AVR????
The Real Elliot (author)  elbriga3 years ago
It's pretty hard to fry them.  I bet the chip is fine.

Generally, it shouldn't matter whether the resistor is on the + or - side of the LED -- it limits the total current flow just fine in either location.  Something else is going on...

Double-check your wiring?  Do you have all the programming lines going to the right places?  

Another possibility is that you've got flakey power supplied to the chip.  The solution is to buffer the power supply.  That is, place a 1uF - 10uF capacitor across the positcheap trickive and negative power rails, or even better across the Tiny's VCC and GND pins.  This will smooth out voltage spikes in the power line that might be accidentally resetting your chip.

suyog143 years ago
thnks for detail description but I hav to interface it wid  PIC18F4550.
Can u please fwd ckt dig+c/hex file on
Yakumo4 years ago
thanks for this Instructable, haven't done all of it but it was a great help making my own cradle :)

while programming getting 5V from the USB-Port is the most direct approach so I think you are talking about the running project.
well i only used atmega 168 till now but I think other chips work pretty much the same. You can power the chip with lower than 5V the only disadvantage is you can't run it at the same speed (less MHz). look at the datasheet of your processor.
bha1234 years ago
 sorry to specify in banglore ,india where can i find these components
cdousley bha1234 years ago

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!