Line 2: Line 2:
 
----
 
----
 
[[Category:AVR Tutorials]]
 
[[Category:AVR Tutorials]]
 +
{{#setmainimage:Blink breadboard bb.png}}
 
This is the first tutorial with AVR where we will get hands on! Let's do a 'hello world' for Embedded. We will interface a simple LED with one of the port pins. The LED as might know emits light when current is passed through it. It could blow up if we pass more current ( >20mA depending on make and type), hence we put a current limiting resistor. Usually 220, 470 and 1K ohm resistors are found. You can use any of these, it should not be an issue.  
 
This is the first tutorial with AVR where we will get hands on! Let's do a 'hello world' for Embedded. We will interface a simple LED with one of the port pins. The LED as might know emits light when current is passed through it. It could blow up if we pass more current ( >20mA depending on make and type), hence we put a current limiting resistor. Usually 220, 470 and 1K ohm resistors are found. You can use any of these, it should not be an issue.  
 
Well instead of a single one, we can as-well connect a bunch of these to port and blink them.  
 
Well instead of a single one, we can as-well connect a bunch of these to port and blink them.  

Revision as of 15:33, 5 November 2015

Sandeep (talk) 09:51, 5 November 2015 (IST)


Blink breadboard bb.png This is the first tutorial with AVR where we will get hands on! Let's do a 'hello world' for Embedded. We will interface a simple LED with one of the port pins. The LED as might know emits light when current is passed through it. It could blow up if we pass more current ( >20mA depending on make and type), hence we put a current limiting resistor. Usually 220, 470 and 1K ohm resistors are found. You can use any of these, it should not be an issue. Well instead of a single one, we can as-well connect a bunch of these to port and blink them.

Hookup

You may look this up with the simple breadboard as shown in section below or you could use the Ultra AVR dev kit if do not wish to jumble with wires and resistors.

Type 1:Breadboard with Explore AVR 40 Pin Breakout Board with Atmega32

Components Used

Buy from EE store

Blink breadboard bb.png


Type 2:Using Explore Ultra AVR Dev Kit

Components Used

The Explore Ultra AVR Kit comes with all the things required, not just for this experiment but for the entire series. And even if you think of migrating to PIC or Arduino, you'll have breakout boards that fit on to this, hence we believe it is a great investment for learning hands on Embedded Systems. The kit is fully open source, you may use the schematics, the design files and all of the source code and build something cool on your own. And when you do that do not forget to share with us what you've done. We would be happy to see you building something cool.

Blink bb.png

Code

#include <avr\io.h>
#include "stdutils.h"
#include "delay.h" //User defined library which contains the delay routines
 
 
#define LedOn 0xFF
#define LedOff 0x00
 
/* start the main program */
void main() 
{
  /*Configure all the ports as output */
   DDRA= C_PortOutput_U8;
   DDRB= C_PortOutput_U8;
   DDRC= C_PortOutput_U8;
   DDRD= C_PortOutput_U8;
 
  while(1)
    {
 
	 /* Turn On all the leds and wait for one second */ 
	   PORTA=LedOn;
	   PORTB=LedOn;
	   PORTC=LedOn;
	   PORTD=LedOn;	   
	   DELAY_sec(1);
	 /* Turn off all the leds and wait for one second */
	   PORTA=LedOff;
	   PORTB=LedOff;
	   PORTC=LedOff;
	   PORTD=LedOff;           
	   DELAY_sec(1);
	  }
  }

Video Tutorial

For those of you, who would like to watch instead of read we have made a video with all the gyan.