A while back, I posted up a quick and dirty "el cheapo" method of getting started programming the Atmel AVR series chips: Ghetto Programmer (version 1.0)

Since then, I've vamped, re-vamped, and otherwise improved my setup. Thought it'd be nice to document it.

The goal was to get a flexible, compact, portable, use-anywhere, AVR-based microcontroller prototyping environment. On the cheap(ish).

So without further ado, here's the Ghetto Development Environment (GDE) (version 1.2).

Step 1: The Kit

The basic kit contains the following stuffs:

USB programmer. Because you want to be able to program microcontrollers from your laptop anywhere. And because USB is a very handy source of +5v.

Programming cradles. One for each kind of chip you're playing with. For me, that means one with 8 pins (ATtiny13, 15), one with 20 pins (ATtiny 2313), and one with 28 pins (ATmega8).

Blinkenlights. When something's wrong with your code, nothing clears it up like sticking lights in to diagnose. Plus, the LED blinker program is the "Hello World" of microcontrollers.

Breadboard. It's a development kit, after all.

Step 2: The USB Programmer

In Ghetto Programmer (v.1.0) I used a parallel port programmer. It's great because it's simple and cheap and fast. But my laptop doesn't have a parallel port.

I played around with making serial port programmers for a bit, but honestly they're just as complicated as the USB version and even serial ports are becoming scarce.

Indeed, my laptop's only really got USB. So USB it is. Looking around, the USBTiny programmer is pretty simple and works with the free GNU/AVR-GCC tools.

Do it yourself or buy a kit?

The DIY way is good if you can already program an ATTiny2313 (with parallel programmer) and have a 12MHz crystal sitting around. USBTiny Page lays out the basics.

He terminates the programming cable with a parallel port, but I'd finish it up in a standard 6-pin header if I were starting afresh. (Why? Because it's standard.) Here are his pin-outs, and check the image below for the cable layout.

PD5 - Reset

If you make your own, please learn from my experience and put it into a nice plastic box. If you don't, it'll fail eventually when the 12MHz crystal breaks off. Which is why I now use...

The quick-and-elegant way is Ladyada's USBtinyISP kit. It'll set you back $22, but you get a nice PCB, pre-programmed ATTiny2313, and a clean box with nice cables. Raw parts are like $15-16 anyway, and you don't have to call up Digikey and then worry about programming up your own 2313. Takes 30 min - 1 hr to solder it all together.

Splurge. Trust me.

(No affiliation, satisfied customer)

And just saw this link: Ladyada's AVR Tutorial which seems pretty good to me.

(And do note that Ladyada's design and the original USBTiny use different USB product identifier codes -- you'll have to find the ID strings and re-compile avrGCC if you're switching between the two. I think there's instructions on the respective webpages.)

In case you're on a Ubuntu Linux system and using the USBTiny programmer, here's the commands that'll get the whole toolchain up and running:

sudo apt-get install build-essential avr-libc binutils-avr gcc-avr avrdude
(tested on Hardy Heron)

If you have an AMD64 arch, you may also need: byacc libusb-dev flex bison libc6-dev
and then to compile AVRdude by hand:
wget http://download.savannah.gnu.org/releases/avrdude/avrdude-5.5.tar.gz
tar xvzf avrdude-5.5.tar.gz
cd avrdude-5.5
## Patch needed for AMD64:
wget http://savannah.nongnu.org/patch/download.php?file_id=14754
patch -p1 < avrdude-5.5.usbtiny.64bit.patch
make && make install
sudo avrdude -p attiny2313 -c usbtiny ## to test

If you see something like "avrdude: AVR device initialized and ready to accept instructions" then you're done.

Oh yeah, and credit to Wendel Oskay for the diagram of the standard programmer pinouts.

Step 3: The Programming Cradle

In Ghetto Programmer v.1.0 I used a programming cradle with a non-standard pin input and with female pin-headers to stick stuff into.

Non-standard pins are a bad idea because you'll not be able to use your cradle with someone else's programmer, and vice-versa.

Female pin-headers were fun because you could directly plug LEDs into them, but when I'd start doing something more complex, I'd end up wiring it into a breadboard anyway. With the new cradle, I cut out the middleman. Less hand-wiring = better.

But the biggest advantage of this cradle design is that you can plug in the cradle almost anywhere you could plug in the AVR chip. This turns out to be huge. Instead of designing ISP circuits into your robot or whatever, you just stick this cradle thing into the IC socket. Then you can program/re-program your robot's brain in circuit. When you're done developing, plug the AVR in directly and you're on to the next one.

Making the cradles is easy enough -- all you need to do is connect the pins from the 6-pin header to the right places on the chips. This time 'round, I used etched PCBs. You can just as well hand-wire the whole thing on perfboard.

The ATTiny13/15 cradle is made with an 8-pin wire-wrap socket. I love these. It's easy to insert the chip into its nice round holes and the long legs provide extra clearance on the breadboard. I made the PCB traces by freehand with a Sharpie.

The ATTiny2313 cradle was made with Eagle and the laser paper toner transfer method. I couldn't find any 20-pin wire-wrap sockets, so I had to resort to a 20-pin regular socket soldered onto 2 10-pin pin headers. This ends up with a cradle with shorter legs, but it works. The schematic and the PDF I used for the circuit are below.

On both, I had to hand-wire an extra line. Such is life.

Step 4: Blinkenlights

Simplicity itself. I wouldn't mention these at all if they weren't so damn handy.

Solder a resistor (150-220 ohms is a good value.) straight onto the negative lead of some LEDs. It'll light up from around 2v-6v without burning out.

And the resistor helps you to remember which side is negative.

Stick them wherever you want to know there's electricity. Figure out if that transistor is blown. Turn a nicad battery pack into a long-lived nightlight.
Use a blinky-code interface to read values out of your microprocessor (slowly). Or make 8 of them and you've got a one-byte display (plus the active ingredient in Cylon eyes.)

Make them. Make many. Make them now.

Step 5: The End

So this "system" meets almost all my development needs. It's modular, scalable, compact, and portable.

For instance, I worked out the routines for running scrolling messages on the 4-digit display (intro page) on the plane on the way to a friend's wedding. Makes a good icebreaker with the flight attendants.

This potientiometer -> ADC -> PWM-driven ammeter setup was breadboarded, coded, and debugged entirely between my couch and dining table, and cleans up in like 2 min when friends come over. (It's the alarm-time-setting part of what's going to be a meter-clock.)

I bring the setup to work sometimes when I feel like playing hooky.

Add a small bag of goodies (some capacitors and resistors, hook-up wire, transistors, piezo speaker, photodiodes, microphones, small motors, etc) and you'll be so far ahead of MacGuyver it's not even funny.

Excellent idea for beginners!! Very handy, congrats!
I did it! i finally set up an environment based on your own setup (using adafruit's programmer). I just want to thank you for putting together these instructables since they helped me finally get into the world of microcontrollers. I ran my first hello world last weekend and am going to try to tackle learning to program next. Thanks again Elliot.
So, I just tried this with the PDF. I'm using Ubuntu 10.10 with evince as my PDF reader. I just finished drilling the board, and was about to fit the IC socket, when I realized the template printed about 0.5mm too small. I should have checked on paper before I toner transferred.<br><br>I should have better instructions soon on how to print this in Linux. Good -able though!
OK - if you're using evince, make sure to go to &quot;Page Handling&quot; in the print dialog and change &quot;Page Scaling&quot; to &quot;None&quot;. That fixed it. What a silly default setting!
i would like to know how you pulled off breadboarding on an airplane
The winavr make file creator or gui is kinda nice it would be a great thing to have a tut on useing the USBtiny and boarduino because then it would be open source hardware with open source retargetable software creation.
Yeah. I don't really get the appeal of the Arduino stuff. Besides a nice hardware package (especially Boarduino), it's mostly a higher-level programming language than C. For microcontroller stuff, I find that C is already overkill, and I often wish I knew assembler better. The arduino "language" only works with a particular hardware platform, while learning to program up AVRs in a lower-level language lets you use any of the chips, wired up any way you want. Another part of the appeal of microcontrollers for me is that they're so cheap that you can use as many as you want throughout your project. The arduino (at $10-30) forces you into a centralized-processor mentality. The Tiny AVRs are cheap enough that I often use them in place of dedicated ICs, like a 555 timer circuit with the equivalent of the blinkenlights code here. But then you realize it's more powerful -- that you've got a digitally-controlled, accurate 555 circuit. Arduino is probably a good way to get started, though. Just don't be afraid to look behind the curtain at what its "language" is doing for you.
You can program in C within the arduino IDE.
I have used assembly but in the open source world it is easier to communicate your objective in c and comments than asm and comments. At least I would think so when your project does a bit. I like the boarduno because I will use the eagle cad files to make it much more soon. In steps first I will add opto couplers and dc to dc converter this will seperate the boardunos power supply and the people safer boarduno circuitry. The design is based off of the modualar eeg you can find it by searching under open eeg. I do not want to re-invent the wheel so I use open circuit designs.
Yah, totally. I absolutely agree about C being more fun to read/write than assembly. I may have come off too harsh on the Arduino stuff. Basically my point is that I like tailoring the circuit designs for my applications, rather than having a pre-built for every occasion. If you need a pre-built, the Arduino seems a good one, and the availability of standard schematics and the corresponding software is a powerful combo.
Would you like to look at the open eeg design and assist with a improved version of the modular eeg? My open source project is at pceeg.sourceforge.net and open circuits but the website needs updating.
Does the programmer work with winavr?
I would really like to start out using microcontrollers. I've done other things with simple circuits (resistors, leds, transistors, etc.) and this seemed like the next logical step. problem is, I can't really find any good resources for starting out (everything starts to seem like an endless loop of &quot;you must know A to know B, you must know B to know C, and you must know C to know A.&quot;). if anybody could help me out, I'd really appreciate it.<br />
By now, I imagine that you have found a way to begin programming microcontrollers (mcu's). If you have not, there are a few ways to get started. One way is to find a supplier (there are many on the web) that sells a beginner's kit and go from there. <br> <br>These kits often include the mcu, a programming cable, a breadboard, some jumper wires, components, and a book. If you are looking for an instructable that will get you started, it is a little harder. To get started, I would get a starter kit. You can build your own when you get more comfortable with mcu's. <br> <br>I am currently searching for an instructional site that will show me how to build an mcu from scratch. These sites often recommend you purchase a programmer and go from there. I have yet to read through this whole instructable and hope it provides the knowledge I need. <br> <br>A combination of both the least expensive and the kit is to look at a kit, buy the components in bulk (useful in the long term but often actually more expensive at the beginning), buy the mcu, and look for the book at your local library or your univeristy or community college library. If your library does not have the book, request it. <br> <br>One more suggestion, if you want to go absolutely on the cheap and would risk getting sidetracked by a parallel project (computer generated art), start with Processing (at http://processing.org) and work your way into Arduino. Why? Processing and Arduino are very closely related. The language for Processing is very similar to Arduino and the programming environment is also very similar. You can learn Processing very extensively from the website and there are a number of books about it. <br> <br>Good luck.
I actually am right now taking a digital electronics class. I'm doing pretty well (finished my first on-my-own AOI logic circuit from a word problem today, actually) and I'm hoping to learn some programming there.
i want to make usbtinyisp&nbsp; v1.0<br /> how to program the firmware ?
Hello, I&nbsp;have followed this instructable exactly except when I try to hook up a keypad matrix it does not seem to work. I am using CodeVisionAVR and have tried many different combinations to make this work. Could this be the cradle or ISP programmer, my code, or wiring? I&nbsp;seem to have made everything correct except it doesnt work correctly.<br /> <br />
here's a cheap usb based isp programmer <a rel="nofollow" href="http://shop.extremeelectronics.co.in/product_info.php?cPath=21&amp;products_id=28">http://shop.extremeelectronics.co.in/product_info.php?cPath=21&amp;products_id=28</a><br/>
I tried that Extreme Electronics - be aware that they are located in India and charge a huge amount for shipping! They use DHL and the shipping for the programmer was over 500% of the cost of the programmer to ship to the USA. And they quoted a very reasonable shipping price and took my PayPal payment with no difficulty. AFTER all that they stopped my order and added the shipping charge. To be fair, they did refund my PayPal amount, but I thought that taking my money first was pretty bad. Just be aware, that if you are not in India, you need to get the shipping price quoted separately from your purchase. I will be ordering from Lady Ada soon.
It looks like SparkFun.com carries the 20 pin wire wrap sockets that you were having difficulty finding.
You really should give me credit if you're going to use my drawing....
you do have credit. it says thanks to wendel oskay atop of the drawing
I changed that after he mentioned it. It was an oversight. I've been using his drawing of the pinouts for a while now, and totally forgot where I cribbed them from.
Its Windell. I think
And who is that?
you mean "build-essential" not "build-essentials"
Yikes. Thanks.
I have seen these on ebay for like 7.50 pre-made.. might be worth a shot buying.
Wow,instructibles.com redirects you to instructables.com
wow, look at that batman!
I Think you Made a mistake at commenting
no mistake
why did you reply to me then?
because i felt like it.
You mean you posted random spam?
no, it was purposefull.
I just Love instructables! (<sup>_</sup>)<br/><br/>1 Q about the 27pF capacitors, I just couldn't find it in my local stores.<br/>Can I replace them with .1uF, 1nF or 100pF?<br/><br/>Thanx for your help...........<br/>
Ok so i'm wanting to try out my first microcontroller. I know about electronic just not this stuff. Do you recoment going with this or Arduino. What are the pros and cons of them both. I'm not worried about putting the kit together. I'm just worried about programming, cost and help if needed.
Good question on the pros and cons! Pros for the Arduino include: It's very easy to learn on, and it's got a USB programmer built in. Arduino abstracts away some of the tricky programming concepts, so it's easier to get something simple up and running quickly. Cons include: The Arduino is much more expensive per device, and it's less flexible and powerful than coding for the raw chip (but not by all that much).
an ibm thinkpad,nice
Ok a simple solution to fixing both of those is to make the board a little wider... No problem there.
I've read both of your Ghetto Instructables and I had a questions about the cabling used: I have a FTDI TTL-232R-5.0V, I'm thinking I can just use that like how you did in version 1 but as USB instead of parallel? Or am I missing something? Also whats the 2313 actually DO in ladyada's ISP? I'm just learning this stuff, so please assume I don't know everything :) Blinkenlights are great!
Is there any other way to get the code onto the chip than moving all around your computer to find the file then typing in -c usbtiny....
I <em>think</em> AVR studio bypasses that. <br/>
not with a usbtiny. I cant get the patch to work.
I think I'm gonna stick to the USB programmer available from atmel, the mkII or something. Even if you have to use external power for the chip, I'm just scared I'll mess something up in the soldering process of ladyada's programmer. I don't really understand the numbers in the code for assigning inputs/ outputs and highs/lows. The 0xXX ones? Any help with explaining those would be nice.
Help when I try to follow the ladyla instructions it says that it cannot find USBtiny device. I have tried to install the drivers. Maybe I soldered it wrong but I checked and tipple checked that all parts were in place. I did not switch those resistors for leads. Would that be a problem?
How do you make the hex files from a c file?
which os are you using?

About This Instructable




More by The Real Elliot:Clean and Grease your Skateboard Bearings Quickie PCB Production (with Bonus NiCd Battery Charger) Stop using Ferric Chloride etchant!  (A better etching solution.) 
Add instructable to: