LED Glow using ATmega32 – step by step

Figure shows the circuit diagram of the model in which LED is used for glow a LED.

One led is connected to C0 pin of PORTC, using 330 Ohm of register. how to calculate register value to glow an led? we use given formula to calculate the register value::

R=5V/10mA= 320 Ohm or 330 Ohm.

When controller gives an output as logic 1 at C0 pin, then the led will glow.

Lets start with circuit diagram:

We used ATmel ATmega32 Microcontrollers to operate the led.

This circuit diagram is includes on board +5V power supply with Reset button to reset ATmel ATmega Microcontroller.

You just open the ATmel AVR Stuido to write & compile the program for ATmel ICs. For this we will refer to our another post “how to start with ATmel AVR Studio”. For download AVR Studio, Please visit to ATmel website or click here to download AVR Studio.

first of all we include the avr lib to program as written program

#include<avr/io.h> // AVR Lib

void main() // Body of the program
DDRC=0b00000001;  // Set the direction of C0 pin as output (1)
PORTC=0b00000001; // set the voltage for pin C0 (1)

When compiling done, AVR Studio will generate a hexadecimal file include program name as ledglow.hex (if we save program name as ledglow)

After this you can see the results of your program in Proteus simulator to check that your program will work same as the them program you have created.

so you have to download the proteus software from Labcenter electronics site  for AVR microcontroller or go to this link to download location.
After that you have to pick & place ATmega32 microcontroller & led as the proteus simulation given below.

Paste the .hex file location to the ATmega32 by using double click on Atmega32 microcontroller. After it you run it & you will see that led will glow as per our instruction in program. 
Thank you very much. 
This program has taken from the book “Embedded System based on ATmega Microcontroller” chapter no 7, ATmega interfacing with led.

Feel free to suggest or post your query for any problem.