Here we are going to discus about:
  • Writing hello world avr program with C – GNU compiler
  • Designing simple hellow world circuit with Proteus
  • Blinking led with simple C scripting and delay() functions
As we know how to compile C/C++ avr code on the previous article. Now let's apply the method again to to make our hello-world program, it is a simple blinking led program. here the explanation will be more concerned about setting registers and gnu-avr features. beginning from header file, main() function and _delay_ms() function, register accessing, and a little bit about bitwise operations.
As always, a proteus application will be used as our simulation here and also avr from GNU compiler to compile our code to generate hex file.

That's it!, just make a circuit like below in the proteus program

Figure 1 atmega8535; PORTA.0 to the led
Then type the program below on your favorite text editor:
#include <avr/io.h>  //DDRA, PORTA
#include <util/delay.h> //_delay_ms()

//“main” function must exist
int main(){  
 //activate A register on the first bit
 DDRA |= 0x01; 
 
 while(1){ //endless loop
  //assign HIGH logic to its first bit of A Register, led turns on
  PORTA |= 0x01; 
  //wait for 250 milli second
  _delay_ms(250);
  //assign LOW logic to its first bit of A Register, led turns off 
  PORTA &= ~0x01; 
  //wait for 250 milli second
  _delay_ms(500); 
 }
 
 //integer return type for our main function
 return 0; 
}
Then compile the above program (by previous artile method), and insert the hex file having been generated into the MCU of proteus simulation. Don't forget to set the CPU speed according to the speed when we compile the program (-DF_CPU=2000000UL), in this case, the clock speed is 2MHz.
Figure 2 inserting hex file and setting CPU speed
Run the program to see the result, it must be blinking.

Related Post:
Note:
On the post linked above explains more about the operation register and bitwise operator based on this post code example.