Arduino Bootloader and Sketches on ATmega32

I have a bunch of ATmega16 & ATmega 32 (40-pin DIP), and I want to use Arduino IDE with it, to program them for various projects related to robotics (Like- taking readings from a bunch of sensors, driving DC motors and servos, that kinda stuff). I also have a USBASP programmer (6 pin out).

How can I put the Arduino bootloader on the ATmega32? What files need changing? Is there another programmer that is better for this?

Also, what else do I need (hardware and/or software) to connect the ATmega32 to a computer to 1. upload Arduino sketches onto it, and 2. be able to use the Serial.read and write commands?

I have the latest Arduino IDE version installed.

I'm kinda new to Arduino so it would be great if you could tell me the step by step process and the necessary hardware pin connections too.

Others have done this before. Check these out.

http://forum.arduino.cc/index.php?topic=174311.msg1305374#msg1305374

http://forum.arduino.cc/index.php?topic=172881.msg1285533#msg1285533

Thanks, These seem to help with the changes I need to make in the IDE, but they don't really go into the necessary hardware that I need to upload the bootloader and the sketches. That is why I was wondering if anybody had done a full tutorial on it that tackles both the hardware and the IDE. I haven't found one so far. I am planning to create a circuit on a breadboard first and then if that works, I will solder it all onto a general purpose PCB. So later I can just attach the USBASP, (and maybe the FT232RL USB to Serial break-out board from Sparkfun, I don't know what that's for, and if I need it or not. www.sparkfun.com/products/718 ) to the general purpose PCB and use it on all the Atmega16/32 I have.

The basic standalone designs will be the same as an ATmega328P just adjust for the different pinouts of the mega16/32.

1) VCC and GND 2) Decoupling capacitors, 0.1uF ceramic type. Close to each VCC and GND pins as possible. 3) 10Kohm pull-up resistor to the reset pin. 4) Optional: External clocking, Crystal oscillator and 22pF capacitors. 5) Optional: Bootloader support, Tx/Rx pins, and auto-reset circuit (0.1uF capacitor between DTR and reset pin) (Typically you would put a 1x6 pin header for the standard FTDI pinouts, https://www.sparkfun.com/products/9716) (You can skip the bootloader and put on an 2x3 ICSP header for ISP programming, you will need this to burn bootloader anyway)

Some basics here:

http://www.gammon.com.au/forum/?id=11637

I don't think my bootloader-uploader handles the Atmega32, but you could use the chip programmer:

http://www.gammon.com.au/forum/?id=11638

Perhaps others have found it out as well. Here you can download a 'hardware' dir you can simply unzip in sketchfolder/hardware containing old stk500 style bootloader, adapted boards.txt and a pins_arduino.h file for ATmega32:

http://wiki.edwindertien.nl/doku.php?id=software:bootloaders&#arduino_bootloader_for_atmega32

Regards, Edwin

I found this link- http://achuwilson.wordpress.com/2011/12/15/arduino-ide-for-programming-atmega-microcontrollers/

Haven't tried it yet, but it looks promising though!