LED blinking AVR

July 25, 2009 by admin
Filed under: Microcontrollers 

Blinky Program for AVR LED is connected to PORTC_5 in sinking mode that is active low.

led blinky deveshsamaiya

#include<avr/io.h>  // Header file for basic avr input/output

#include<util/delay.h> // header file for delay generation

#define BV(x) (1<<x)

int main(void)

{

DDRC=0xFF;   //portc declared as output

PORTC=0xFF;   // PORTC is initially high to off the led initially

while(1==1)   // infinite loop as 1 is always equals 1

{

PORTC=~(BV(5));    // led glow here

_delay_ms(1000);   // one second delay

PORTC=BV(5);        // led not glow here

_delay_ms(1000);

}

return 0;

}


Comments

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!





Anti-Spam Protection by WP-SpamFree