Blinking LEDs using AVR (ATMEGA 32)

SIMULATOR: PROTEUS 8.0

SOFTWARE: WIN AVR

CIRCUIT DIAGRAM:

CIRCUIT DESCRIPTION:

Here, LEDs are connected to the port b register of AVR.

I have used the current-sinking arrangement. Therefore, I have provided logic 0 to turn on the LED and logic 1 to turn off the LED.

PROGRAM:

#include<avr/io.h>   

void delay(unsigned int t); // delay function

int main(void)    // main program

{

DDRB=0XFF;  //  Select PORT B as an output port

while(1)             // continuous loop

{

PORTB=0X00;  // turned on the LEDs

delay(10); // delay 

PORTB=0XFF; // turned off the LEDs

}

}

void delay(unsigned int t) // delay function

{

unsigned int i;

for(i=0;i<1275*t;i++);

}

PROGRAM DESCRIPTION:

DDRx:

Here, DDR stands for data direction register and x represents the port number.

Here, I have used port b. So, in place of x,I have written B.

It is used to decide whether the port is acting as an input port or an output port.

DDRx=0X00; // port x is acting as an input port.

DDRx=0XFF; // port x is acting as an output port.

PORTx:

In this x represents the port number.This register is used to send the data to the respective port.Here, I have used port b. So, in place of x, I have written B. 

In this project, port b is acting as an output port. Hence I have set DDRB as 0xFF.

I have provided 0x00 to the port b. So that, I can turn on all the LEDs connected to it. After that I have provided some delay.Then to turn off all the LEDs connected to the port b, I have provided 0xff to the port b.

VIDEO:

 


 

Comments

Popular posts from this blog

Digital Thermometer using 8051 and ADC 0808 Interfacing With 8051

how to display numbers on lcd?

To display custom characters on the lcd using 8051 micro-controller.