Introduction: ATmega8 As Arduino (using Internal 8Mhz Crystal)
Nowadays, gadgets like Arduino have found a very popular use. They can be used to create a plethora of projects, however, they occupy a lot of space and are expensive for some of us (including me). To solve this problem, I present to you this instructable, which will teach you how to use an ATmega8 (or any other avr) chip to store Arduino code and act as a compact and cheap Arduino. Doing this requires easily available electronics, which, if you are a hobbyist too, will already have. Unlike other instructables, which depend on the usage of an external crystal oscillator to achieve the same goal, this project uses the internal 8Mhz crystal of ATmega8, which makes it a boon for those who lack the 16Mhz crystal.
Also, I will be using an Arduino as an ISP to program the chip, so this makes it more cheap.
Now, without further ado, let's begin tinkering!
Step 1: Gather Around Some Stuff and Some Files
1. 10uF capacitor - 1
2. Male to Male Jumper Wires - 8
3. Breadboard - 1
4. ATmega8 chip - 1
5. Arduino UNO or any other Arduino
Stuff To Download:
This link will lead you to the Arduino IDE Downloads page. Download the v.1.0.1 specifically because I have found it to work perfectly with the ATmega8 chip. For some reason, latest version doesn't support the modification of Boards.txt, which is crucial for this instructable.
The usage of this file will be explained afterwards.
Step 2: Converting Arduino Into a Programmer
Arduino can be converted into a programmer by simply uploading the ArduinoISP sketch to it. It is provided as an example sketch by Arduino. However, I am providing the code as a file too. Download it and upload it to your Arduino.
Once the code is uploaded, proceed to the next step.
Step 3: Setting Up Arduino V1.0.1
After downloading Arduino v1.0.1, extract it. Also, copy the whole text of "boards.txt" file you downloaded.
1. Now you have to browse the following file in the extracted folder:
2. Open "boards.txt" and paste the copied text at the end of the file.
3. Now open "arduino.exe" placed in the extracted Arduino 1.0.1 folder.
4. Select the Arduino board as "ATmega8-noxtal @8MHz"
5. Select the Programmer as "Arduino as ISP"
Now your Arduino IDE v1.0.1 is set up!
Step 4: Hooking Up Arduino With ATmega8
Wire the ATmega8 IC with your Arduino by referring to the above posted schematics.
Also, keep in mind to place the 10uF capacitor between the RESET and GND pins.
I have attached a picture of how I had wired my Arduino to ATmega8.
Step 5: Burning the Bootloader to ATmega8
Bootloaders are the files which enable a microcontroller to be programmed independently. Therefore, once ATmega8 is burnt with a bootloader, we will be able to use it as an Arduino.
To burn the bootloader:
1. Extract "atmega8_noxtal.zip" to ".......\arduino-1.0.1\hardware\arduino\bootloaders\".
2. If Arduino IDE is already running, restart it, else open it.
3. Check if the Programmer, COM Port and Board is correctly set as described in one of the previous steps.
4. Hit "Burn Bootloader" under "Tools" menu.
If you have wired correctly, on clicking the "Burn Bootloader" option, the RX,TX, and L lights on the Arduino will start glowing brightly. I have posted the picture too.
Step 6: Uploading Sketches to ATmega8
After burning the bootloader to your ATmega8, you have almost finished this project.
Now all that's left to do is to upload your desired sketch to your chip. To do that, ensure that the board is set to "Atmega8-noxtal @8Mhz", and the programmer to "Arduino as ISP".
Remember that the wiring which you had used to burn the bootloader is also used for uploading sketches.
Uploading the sketch is done by using Arduino as a programmer, so unlike usually, when you pressed "Ctrl+U", now you will have to press "Ctrl+Shift+U", which tells the IDE to program the chip through Arduino.
Step 7: Congratulations!
Now all that's left for you is to power up your ATmega8 through a 5V power supply with the following connections:
- VCC of Power Supply to Pin 7(VCC) and Pin 20(AVCC)
- GND of Power Supply to Pin 8(GND).
If your project doesn't require or use any analog pins, then the connection of VCC to Pin 20(AVCC) may be ignored!
Congratulations on successfully converting your ATmega8 chip into a mini Arduino. Now you can make your projects much more compact and cheap. To understand its pin relation with Arduino pins, refer to the above posted schematic.
I have posted the picture of my ATmega8 powered through Arduino UNO 5V (I didn't have any other power supply) and programmed with Blink sketch.
Also, if you have found this instructable helpful, please support me by reopening the shortened download links twice or thrice.
That's all for this instructable!
If you have any doubt, feel free to comment.
Thanks to Ashish Choudhary for lending his camera.