ATmega32 Basic Tutorial Led Blinking using AVR Studio 5

This is a very basic tutorial for atmega32 microcontroller beginners to get started. You can call this little program as Hello World for atmega programmers.

LED Tutorial Requirements:

  1. IDE and Compiler Recommended AVR Studio 5
  2. Wiro Board or Skills to design PCB according to the under given schematic
  3. ATmega32 microcontroller
  4. (1)10k resistor
  5. (8) 330 ohm  resistors
  6. (8) Leds
  7. (2) 18 pf capacitor (for xtal crystal oscilator drive)
  8. (1) XTAL crystal Oscilator of any frquency within the limits recommended 4MHz
  9. 5 Volts DC Power Source to drive the circuit

Schematic Diagram for ATmega32 Led Blink Circuit:

atmega led blink schematic circuit diagram

LED Blinking Code:

code is written in C language.
/*
* ledb_blinking_using_Atmega.c
*  Author: Bailal Ayoub
*/
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRB=0xFF; //Setting all pins of PORTB as output
PORTB=0×00; //Initializing PORTB as Zero (or Sending LED OFF Instruction)
while(1)
{
//Project Code Starts from Here
PORTB=0xFF;  //Enabling LED
_delay_ms(200); //giving 200 milisec delay
PORTB=0×00; //Disabling LED
_delay_ms(200); //giving 200 milisec delay
} //while 1 loop ends
} //main ends

Step 1:

Create above circuit using components mentioned in project requirements on Wiroboard or create using PCB.

Step 2:

You need to have ATMEL AVR Studio 5 IDE and compiler. Which will help you to write and edit the C language Code easily. Insert the above source code given C Language code in the avr studio.

Step 3:

Compile the code and create the HEX file

Step 4:

Burn the Hex file to atmega32 Chip using any avr programmer or you can create your own avr usb programmer

Step 5:

Power the circuit and you will have led blinking with the delay of 200 millisecond.


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top