Driving 2 LED in a Fasion

21 Jan 2013

image

This code make 2 LED blink one after other. LEDs are connected to PORT C (P0 and P1). Make sure use a 330 ohm resistance to protect your LED.Code

 /*  
  * Driving_2_LED_in_a_Fashion.c  
  *  
  * Created: 01-01-2013 PM 12:24:34  
  *  Author: ANANTHAKRISHNAN.U.S  
  */   
   
   
 #include <avr/io.h> 
 #include <util/delay.h> 
  
 int main(void) 
 { 
   DDRC = 0b00000011; 
     while(1) 
     { 
      PORTC = 0b00000001; 
      _delay_ms(500); 
      PORTC = 0b00000010; 
     _delay_ms(500);  
     } 
 }