Here is a recipe for using the atmega168 as a standalone arduino. It uses the internal oscillator of the arduino running at 8mhz, and is powered at 3.3 volts. I used this together with a xbee radio modem for my wind-up birds project.
You can find out more about how I used the minimal arduino to control a xbee network here.
The only external components needed is a 0.1µF capacitor and a 1k resistor.
The tricky part is to get the firmware onto the chip. You need some sort of avr-programmer, I use the avr-hid developed by Martin Howse.
This procedure is bypassing the bootloader which is used on the atmega chips that come with the arduino boards.
Different programmers use different layouts for the in-system programmer [ISP] header but for the avr-hid it is 1. MOSI, 2. V+, 3. x, 4. GND, 5. RESET, 6. GND, 7. SCK, 8. GND, 9. MISO, 10. GND
please read the instructions for your programmer carefully, there might be some headers for different settings.
I made a custom connector for the atmega168 since I needed to program many chips, also for outdoor use, but else you could of course just hook this up on a breadboard.
MOSI – pin 17
MISO – pin 18
SCK – pin 19
Remember to also hook up ground and power connections.
Open the arduino application.
Update (march 2011): If you are using Arduino 17 or later there is a slightly different procedure, since the Arduino environment is packed inside the application bundle. To get the address of the temporary file, use “verbose verify”, which means the arduino software logs everything it does when compiling the code, including the address of the temporary file, which is the last line from the verbose output. To access verbose output, simply shift click on the verify sketch button.
Copy the address of the temporary file, and then you can more or less follow the recipe below. However, avrdude is now contained within the arduino application bundle, and I haven´t figured out how to access it from a terminal application. Instead I just keep a copy of a pre-Arduino 17 folder, and use the avrdude which came with that version.
Select lilypad as the board in the arduino tools menu. This is because the lilypad also runs at 8mhz.
Verify your arduino sketch, this creates a hex file in a tmp directory which will be used by avrdude.
Open a terminal program, you will access a program called avrdude to program the chip.
avrdude is installed with the arduino software (correct me if this is not the case for some platforms)
in the terminal, navigate to hardware/tools/avr/bin inside your arduino-0011 (or whichever version you are using) folder:
copy the temporary sketch into this directory:
cp /tmp/build*/[filename].hex .
then after making sure your avrprogrammer is connected with a chip ready to get programmed, enter:
./avrdude -C ../etc/avrdude.conf -p m168 -c usbasp -U flash:w:[filename].hex -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m
It was a lot of contradictory information online about the fuse settings, but at least we have had no problems with the above settings.
If everything goes well you will eventually get this message: “avrdude done. Thank you.”
Your minimal arduino is ready to be used!
This might be a useful diagram when programming and hooking up external components: