Toll-Free Customer Support 24/7

LED Blinking Code for Atmega

# define F_CPU 1000000UL
#define FOSC 16000000L //here we define the clock frequency
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRB = 0xFF; //Makes PORTC as Output
While (1) //infinite loop
{
PORTB = 0xFF; //Turns ON All LEDs
_delay_ms(1000); //1 second delay
PORTB= 0x00; //Turns OFF All LEDs
_delay_ms(1000); //1 second delay
}
}

 

Back to top