AVR ATmega8 LED Blinking

In the last section we worked on the hardware part. Now lets start our work with the software.

Open you programmer pad and type the code as shown below:

Progrom

You will get the code file, you need not to type all of it. But you can try it for better understanding.

In main.c file , first we give little description of the code which we are going to write. So that whenever we come back and look on code we can easily identify that for which task the code is written.

Than we need to include some header files.

#include <avr/io.h>

It is required in the beginning as it has all the information about the controller which is useful for the compiler to compile the code.

#include <util/delay.h>

To generate delay required in the code.

Than we start with main() function. This is the most important function required in C programming as everything written in the main() will be called by the compiler.
You might feel these stuff  li’l boring. So just leave it for now and keep going with the same format.

In the start of main() we need to set up input and output configuration of PINs also as explained.

In the main we will also have to include an infinite loop required to run the code continuously.

Leave a comment