Monday, November 13, 2017

AVR LED blinking - 2

Name: LED Blinking
Microcontroller: ATMEGA16
Description: This is very simple hello world poject.  All the pins of Port-D will be ON and OFF (one after one) with a certain period interval.

Code:
void main() {
  DDRD = 0xFF;           // Set the port-D as output

  do {
    PORTD = 0b00000001;        // Turn ON LED#1 on PORTD
    Delay_ms(100);                    // 1 second delay
    PORTD = 0b00000010;        
    Delay_ms(100);      
    PORTD = 0b00000100;        
    Delay_ms(100);      
    PORTD = 0b00001000;       
    Delay_ms(100);
    PORTD = 0b00010000;      
    Delay_ms(100);     
    PORTD = 0b00100000;        
    Delay_ms(100);
    PORTD = 0b01000000;       
    Delay_ms(100);
    PORTD = 0b10000000;        // Turn ON LED#7 on PORTD
    Delay_ms(100);
  } while(1);            // Endless loop

}

No comments:

Post a Comment