This is a simple blinking LED program. We will look at basic structure and cover specifics about the syntax.
First let’s talk about the files that surround the main document you
created. These are called “includes” and they bring code into the main
document. This code adds or augments the functionality of your code.
Includes can be found in the WinAvr folder and in the current project
folder. This include is outside the project folder and uses the <> around the name
#include <avr/io.h>
Schematic
Program
/***********************************************************
Program : LED Blink.
Software:
IDE: Atmel Studio 4
Compiler: avr-gcc
Microcontroller - Atmega 16
Port B : LED
Copyright (C) 2014 - 2016 H.E.A.R.T. Tech Solutions, India.
************************************************************/
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0b1111111; // PORT B All Bits Declared Output
PORTB=0b00000000; // PORT B All bits Intialized with Zero
while(1)
{
PORTB=0b11111111; // PORT B - All Bits ON
_delay_ms(500); // Delay
PORTB=0b00000000; // PORT B - All Bits OFF
_delay_ms(500); // Delay
}
}

Comments
Post a Comment