user5050: I am making an RGB LED project right now using the Arduino UNO board.
At this point everything is working fine so I would like to transfer this onto a small microcontroller circuit to be put inside the enclosure. Since the enclosure is small, I cannot fit the UNO board inside it, hence I want to make a small circuit on perfboard with minimal components.
I read that you can burn the arduino bootloader on a standalone AVR (hooked up to power, filter caps and 16Mhz crystal) which can then execute Arduino code.
Any idea how can I do this? Also can I do this on an ATmega8l AVR, since my code is small enough to fit in one? No point wasting a 328 if 8L can do the job.
Thanks!

user1462: The Bootlader
If you want to burn the bootloader to the standalone AVR that you will be using, you can do so using a programmer like the USBasp. Or, you can simply use the Arduino  itself to do this.

Open the ArduinoISP sketch from File > Examples.
Upload it.
Push reset on the Arduino.

Wire it up
Next, wire up the AVR on a breadboard as shown here: Arduino ISP

If you are using a variant/derivative, use a crystal that matches the crystal on your board. You might have not_in_sync() trouble if you don't.
Add a 10uF capacitor between RESET and GROUND on the Arduino, if you are using Uno, or something similar.

Burning the Bootloader
Then select Arduino as ISP as the programmer.

Goto Tools > Programmer.
Select Arduino as ISP.

Now click on Tools > Burn Bootloader.
Verifying it all works
Once that is done, open the Blink LED example and try uploading it to the AVR. You have to use the Upload using Programmer option from File > Upload using Programmer. You can verify if it is successful, by connecting an LED to pin 19 of the AVR, and checking if it blinks.
Notes:

Remember that the pins on an AVR don't map to the corresponding pins on the Arduino, even if they are both the same chips. Search for "AVR to Arduino pin mapping" for your chip on Google. Here's the ATMega8 to Arduino pin mapping.

Don't forget to connect the ground lines of the AVR and the Arduino.

This worked for me using an ATMega8A-PU. It should work with the 8L too.

Post here if you have any problems. Glad to help :)



5050: <p>I am making an RGB LED project right now using the Arduino UNO board.</p>

<p>At this point everything is working fine so I would like to transfer this onto a small microcontroller circuit to be put inside the enclosure. Since the enclosure is small, I cannot fit the UNO board inside it, hence I want to make a small circuit on perfboard with minimal components.</p>

<p>I read that you can burn the arduino bootloader on a standalone AVR (hooked up to power, filter caps and 16Mhz crystal) which can then execute Arduino code.</p>

<p>Any idea how can I do this? Also can I do this on an ATmega8l AVR, since my code is small enough to fit in one? No point wasting a 328 if 8L can do the job.</p>

<p>Thanks!</p>
 1462: <h3>The Bootlader</h3>
<p>If you want to burn the bootloader to the standalone AVR that you will be using, you can do so using a programmer like the <code>USBasp</code>. Or, you can simply use the <em>Arduino</em>  itself to do this.</p>
<ul>
<li>Open the <code>ArduinoISP</code> sketch from <em>File</em> &gt; <em>Examples</em>.</li>
<li>Upload it.</li>
<li>Push <code>reset</code> on the Arduino.</li>
</ul>
<h3>Wire it up</h3>
<p>Next, wire up the AVR on a breadboard as shown here: <a href="http://arduino.cc/en/Tutorial/ArduinoISP" rel="nofollow noreferrer">Arduino ISP</a></p>
<ul>
<li>If you are using a variant/derivative, use a crystal that matches the crystal on your board. You might have <code>not_in_sync()</code> trouble if you don't.</li>
<li>Add a 10uF capacitor between <code>RESET</code> and <code>GROUND</code> on the Arduino, if you are using Uno, or something similar.</li>
</ul>
<h3>Burning the Bootloader</h3>
<p>Then select <code>Arduino as ISP</code> as the programmer.</p>
<ul>
<li>Goto <em>Tools</em> &gt; <em>Programmer</em>.</li>
<li>Select <em>Arduino as ISP</em>.</li>
</ul>
<p>Now click on <em>Tools</em> &gt; <em>Burn Bootloader</em>.</p>
<h3>Verifying it all works</h3>
<p>Once that is done, open the Blink LED example and try uploading it to the AVR. You have to use the <code>Upload using Programmer</code> option from <em>File</em> &gt; <em>Upload using Programmer</em>. You can verify if it is successful, by connecting an LED to <code>pin 19</code> of the AVR, and checking if it blinks.</p>
<h3>Notes:</h3>
<ul>
<li><p><strong>Remember</strong> that the pins on an AVR don't map to the corresponding pins on the Arduino, even if they are both the same chips. Search for &quot;AVR to Arduino pin mapping&quot; for your chip on Google. Here's the <a href="http://arduino.cc/en/Hacking/PinMapping" rel="nofollow noreferrer">ATMega8 to Arduino pin mapping</a>.</p>
</li>
<li><p>Don't forget to connect the ground lines of the AVR and the Arduino.</p>
</li>
<li><p>This worked for me using an ATMega8A-PU. It should work with the 8L too.</p>
</li>
<li><p>Post here if you have any problems. Glad to help <code>:)</code></p>
</li>
</ul>
