Skip to main content

AVR First Program - LED Blink

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

Popular posts from this blog

3D Printer

What is 3D Printing ? Invented by a man named Chuck Hull back in 1986, 3D printing is a process of taking a digital 3D model and turning that digital file into a physical object. While Hull went on to launch one of the world’s largest 3D printer manufacturers, 3D Systems, his invention concentrated solely on a fabrication process called Stereolithography (SLA). Since that time numerous other 3D printing technologies have been developed, such as Fused Deposition Modeling (FDM)/Fused Filament Fabrication (FFF), Selective Laser Sintering (SLS), PolyJetting and others, all of which rely on layer-by-layer fabrication and are based on a computer code fed to the printer. While there are numerous technologies which can be used to 3D print an object, the majority of 3D printers one will find within a home or an office setting are based on the FDM/FFF or SLA processes, as these technologies are currently cheaper and easier to implement within a machine. We wil...

Capacitors and Its Working

A capacitor is a passive electric element that accumulates energy in the form of electrostatic field. In simple words, capacitor includes 2 conducting plates alienated by the dielectric (an insulating material). The capacitance is inversely relative to the alienation amid the plates and it’s directly relative to the surface area of the conducting plates. Capacitance also relies on the dielectric constant of the material alienating the plates. The customary unit of capacitance is termed as farad, abbreviated. This is a huge unit; other universal units are known as microfarad, abbreviated 1 µF =10 -6 F (µF) & the picofarad, abbreviated 1 pF = 10 -12 F (pF). What is Capacitor?   “An electric circuit element used to store charge temporarily, consisting in general of two metallic plates separated and insulated from each other by a dielectric, also known as condenser.” Basics of Capacitor: A capacitor in general is like a battery....

About 8051 Microcontroller

The Intel 8051 microcontroller is one of the most popular general purpose microcontrollers in use today. The success of the Intel 8051 spawned a number of clones which are collectively referred to as the MCS-51 family of microcontrollers, which includes chips from vendors such as Atmel, Philips, Infineon, and Texas Instruments. The Intel 8051 is an 8-bit microcontroller which means that most available operations are limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard, and Extended. The Short and Standard chips are often available in DIP (dual in-line package) form, but the Extended 8051 models often have a different form factor, and are not "drop-in compatible". All these things are called 8051 because they can all be programmed using 8051 assembly language, and they all share certain features (although the different models all have their own special features). Some of the features that have made the 8051 popular ar...