ATmega328 alternative?

I recently got an Uno (from abroad), and after going through some basic examples, I got the idea to make a simple gift for a friend, which would include just a Piezo buzzer playing a melody (which I've already programmed with the Arduino), and maybe one or two switches and LEDs. But, I don't want to use my ATmega for it, because the project seems extremely simple, so I wouldn't want to waste my 6$ (+ shipping) chip on it, plus I can't find an ATmega328 (or any of the previous ones, I think it's 168 and 8) in my country. So, I came across an AT89C4051-24PU in a local store catalogue. Although I'm a total newbie in electronics, it seems kind of close, and it's only around 3$. But I'm not sure how to program it to do the stuff my Arduino does, and I was wondering is there another IC for the job (but one that I can easily find)?

Here's the datasheet of the AT89C4051: http://www.atmel.com/dyn/resources/prod_documents/doc1001.pdf

There are atmega8's which are compatible with your arduino burlt smaller inside and attinys which are smaller inside and outside but less compatible.

Take a look here http://www.avr-developers.com/ see if there is something purchasable that you could use.

Ok, cool, I just found out where I can get an ATmega8. Unfortunately, it brings another batch of questions:

1) They seem to be selling two "types", or something: ATMEGA8-16AU and ATMEGA8-16PU. What's the difference? 2) When I get one, how do I use it with my UNO? Should I just put it in place of the 328 that's inside right now and program it (and take it out when I'm finished)? 3) Should I burn a bootloader on it first, and how (I'm guessing "w/ Arduino as ISP")? 4) How should I identify it, as "Arduino Uno" or "Arduino NG or older w/ ATmega8"?

Yeah, I know it's a lot of questions. I'm new. :P

  1. Go to atmel.com and search for the datasheet. ATMEGA8-16AU and ATMEGA8-16PU Pretty sure one will be surface mount and will be a plastic DIP
  2. Compare the pinouts, make sure they are compatible. 3a. Probably make it easier to load a sketch that way. 3b. I think you need some components to make it look like an arduino for that to work - plenty of info available in the forum on that.
  3. Search the forum on this also.
  1. They seem to be selling two “types”, or something: ATMEGA8-16AU and ATMEGA8-16PU. What’s the difference?

The “Ordering Information” of the datasheet has the answers. You have downloaded the datasheet, haven’t you?

This is from the 328 datasheet…

AU = 32A package = 32-lead, Thin (1.0 mm) Plastic Quad Flat Package (TQFP)

PU = 28P3 package = 28-lead, 0.300” Wide, Plastic Dual Inline Package (PDIP)

  1. Should I burn a bootloader on it first, and how (I’m guessing “w/ Arduino as ISP”)?

Yes. Yes…

  1. How should I identify it, as “Arduino Uno” or “Arduino NG or older w/ ATmega8”?

I suspect the second option will work without modifications.

3b. I think you need some components to make it look like an arduino for that to work - plenty of info available in the forum on that.

I don't think the external components are necessary to install the bootloader. I believe the programmer provides clocking.

Obviously, the external components [u]are[/u] needed to actually use the processor.