Getting Started with ATmega8 Microcontroller Programming using Arduino IDE.
Since we will program an AVR microcontroller using Arduino, let's first understand what an AVR is. AVR is not an acronym for this microcontroller. It is a marketing term that stands for 'Advanced Virtual RISC'. The ATMEGA328P, ATMEGA88, and their equivalent microcontrollers use RISC (Reduced Instruction Set Computing) architecture, which works faster using fewer instructions.
Through this event, I presented all the easy and accurate processes of Arduino programming and simultaneously showed how to program ATMEGA8, ATMEGA48, ATMEGA88, ATMEGA168-20PU, and ATMEGA328P AVR microcontrollers. Learning to program so many models of AVR microcontrollers at once might be complicated, but no. The AVR microcontrollers mentioned have different capacities, but their circuits and wiring diagrams are the same, so let's get started.
To program an AVR Microcontroller using Arduino, you must first prepare the Arduino as an ISP programmer and upload the Arduino boot loader program to the ATmega8. The task is straightforward; follow the procedure given below to do so.
STEP-1
How to turn Arduino into an ISP programmer
First, connect your Arduino UNO or Nano to the computer using a USB cable. Then, launch the Arduino IDE Software / Arduino program software.
1. Click on the File > Example > select Arduino ISP.
2. Click on the Tools > Board, then select your Arduino model from the board manager.
3. Click on Tools > Port, then select com port (Highlighted com port)
4. Click on Tools > Programmer > ISP > then select AVR ISP mkll.
Finally, upload the Skach by clicking the right arrow button below the menu bar. While uploading, the three indicator LEDs on the Arduino board will start blinking. After a few seconds, when one indicator lights up, and you will see the footer status bar indicating 'Done Uploading', you will know that the AVR ISP program has been successfully uploaded. Okay, now your Arduino is ready as an ISP programmer.
STEP-2
ATMEGA8 Series microcontroller circuit diagram with Arduino
In the second step, insert any one of the ATMEGA8, ATMEGA48, ATMEGA88P, ATMEGA168, or ATMEGA328P AVR microcontrollers into a breadboard, then wire the microcontroller to the Arduino UNO or NANO as per the diagram below.
ATMEGA328P, ATMEGA168, ATMEGA88, ATMEGA48, and ATMEGA8 Wiring Circuit Diagram is below.
How to use ATmega8 with Arduino
![]() |
Arduino Interface With ATmega8, ATmega48, ATmega88, ATmega168, or ATmega328P AVR Microcontroller |
Insert the AVR microcontroller on a breadboard and wire it with jumper wires as follows:
Circuit Diagram: Connect a 22pf Capacitor from IC pin 8 to the ground, then connect one more 22pf capacitor from pin 10 to the ground, and connect a 16Mhz crystal oscillator from IC pin 9 to 10.
Wiring: Connect pin 17 of the IC to digital point 11 of the Arduino, IC pin 18 to digital point 12, and IC pin 19 to digital point 13. Finally, Connect IC pin 7 to the 5V terminal of the Arduino and IC pin 8 to GND or Ground.
STEP-3
Program ATmega8 with Arduino for 4 LEDs sequential blinking
Now launch the Arduino IDE software on your computer, connect the Arduino to the computer via a USB cable, and follow the instructions below for the ATmega8A-PU programming setup.
1. Click on the Tools menu> Board, then select your Microcontroller model (ATmega8 or other) from the Board Manager list.
( If the ATmega8 microcontroller is not on the Board Manager list, download the MiniCore using the following:
How to download and install MiniCore in Arduino IDE?
The video tutorial below shows how to download ATmega8 MiniCore in Arduino IDE via URL).
Minicore URL: https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
2. Tools > Clock External> External 16 MHz
3. Tools > BOD > BOD 2.7V
3. Tools > EEPROM > EEPROM retained
4. Tools > Compiler > LTO enable
5. Tools > Bootloader > Yes (UARTO)
6. Tools > Programmer > Arduino as ISP
Step- 4
Four LED Sequential Blinking Codes for Arduino and ATmega8
// Define the LED pins
const int ledPin1 = 10;
const int ledPin2 = 11;
const int ledPin3 = 12;
const int ledPin4 = 13;
// Define the delay time (in milliseconds)
const int blinkDelay = 500;
void setup() {
// Set the LED pins as output
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}
void loop() {
// Blink LED 1
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
delay(500);
// Blink LED 2
digitalWrite(ledPin2, HIGH);
delay(500);
digitalWrite(ledPin2, LOW);
delay(500);
// Blink LED 3
digitalWrite(ledPin3, HIGH);
delay(500);
digitalWrite(ledPin3, LOW);
delay(500);
// Blink LED 4
digitalWrite(ledPin4, HIGH);
delay(500);
digitalWrite(ledPin4, LOW);
delay(500);
}
Step-5
4 led blinking schematic circuit diagram by atmega8
In the fifth step, remove the jumper connections from the Arduino to the breadboard. Finally, complete the circuit with the ATmega8 and other components as per the circuit diagram below.
Note: This circuit can be used with ATmega8, ATmega48-20PU, ATmega88, ATmega168-20PU, and ATmega328P AVR Microcontrollers.
![]() |
4 LED Blinking Schematic Circuit Diagram Using ATmega8-PU |
Components Number and its Value of the Schematic Circuit Diagram
Microcontroller - Any of one of ATmega8A-PU, ATmega48-20PU, ATmega88, ATmega168-20PU, ATmega328P.
R1- 10KΩ. R2, R3, R4, R5- 330Ω. C1 and C2 - 22PF. X1- 16MHz Crystal Oscillator. D1, D2, D3, and D4- You can use red, green, blue, and yellow LED for 4 LED Blinking.
(To collect an Arduino, you can buy the Arduino UNO R3. This model is the most popular worldwide. Below is a picture of the Arduino UNO REV3).
![]() |
Arduino UNO R3 |
Another post on microcontroller programming: How to program a PIC16F676 PIC microcontroller to make a digital volt meter.
CAUTION: After preparing the ATmega8 four LED blinking project on the breadboard or PCB, double-check for circuit mistakes and apply a 5-volt power supply. Otherwise, the microcontroller may be damaged.
Through this video tutorial, you will learn the Arduino programming method. At the same time, you will learn about the programming of ATmega8A-PU, ATmega48, ATmega88, ATmega168, and ATmega328P.