(22 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[User:Xplore007|Xplore007]] ([[User talk:Xplore007|talk]]) 15:25, 4 February 2016 (IST)
+
 
----
+
 
[[Category:AVR Tutorials]]
 
[[Category:AVR Tutorials]]
<html>
+
[[Category:Explore Ultra AVR Dev Kit]]
<title>The Rock (1996)</title>
+
<meta property="og:title" content="The Rock" />
+
<meta property="og:type" content="video.movie" />
+
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
+
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
+
</html>
+
  
=Objective=
 
 
This is the first tutorial with AVR where we will get hands on. 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. 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.  
  
=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===
 
  
{| class="wikitable"
 
|-
 
| 1||
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/avr-mcu-breakout/1-dsc02958.jpg" width="300 px"></html>
 
  
|| AVR 40 pin breakout board with Atmega32<br />
+
=Register Configuration =
[https://www.exploreembedded.com/product/AVR%2040%20Pin%20Breakout%20Board%20with%20Atmega32 Click here to buy from our store]
+
Please refer the below tutorial for basics of GPIO register configuration.
|-
+
<html>
|2||
+
<ul>
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/breadboard-large/breadboard_large.jpg" width="300 px"></html>
+
<a href="https://www.exploreembedded.com/wiki/2._AVR_I/O_Register_Configuration">AVR I/O Register Configuration
 +
</a>
 +
</ul>
 +
</html>
  
|| Breadboard <br />
+
=Code=
[https://www.exploreembedded.com/product/Large%20Breadboard Click here to buy from our store]
+
Below points needs to be considered for this example.
|-
+
* Include the io.h file as it has the definitions for all the PORT registers.
| 3||
+
* Include delay.h file to use the delay functions.
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/male-to-male-jumper-wires-pack-of-40/1-dsc04497.jpg" width="300 px"></html>
+
* Configure the PORT as Output before writing any data to PORT pins.
  
|| Male to Male Jumper Wires <br />
+
==Blink Leds==
[https://www.exploreembedded.com/product/Male%20to%20Male%20Jumper%20Wires%20-%20Pack%20of%2040 Click here to buy from our store]
+
<html>
|-
+
<script src="https://gist.github.com/SaheblalBagwan/a671ac5b9c722f350a9d.js"></script>
 +
</html>
  
| 4||
+
=Led Blinking Wiring Diagram=
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/led-5mm-red/5mm_red_led.jpg" width="300 px"></html>
+
[[File:Blink bb.png|x480px|center]]
|| LED - 5mm RED <br />
+
[https://www.exploreembedded.com/product/LED%20-%205mm%20RED Click here to buy from our store]
+
|-
+
  
| 5||
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/resistor/3_resistors.jpg" width="300 px"></html>
 
|| Resistor <br />
 
[https://www.exploreembedded.com/product/10K%20ohm%20Resistor Click here to buy from our store]
 
|}
 
  
==Wiring diagram==
 
[[File:Blink breadboard bb.png|x360px|center]]
 
  
==Type 2:Using Explore Ultra AVR Dev Kit==
+
=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.
 
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.
  
 +
[[File:0Blinky AVR.gif|none]]
 
<html>
 
<html>
 
<ul>
 
<ul>
Line 68: Line 46:
 
</html>
 
</html>
  
[[File:Blink bb.png|x480px|center]]
+
=Video Tutorial=
 +
For those of you, who would like to watch instead of read we have made a video with all the gyan.
 +
<br>
 +
{{#ev:youtubehd|-lNAmSNV2-Q|640}}
  
=Code=
 
<syntaxhighlight>
 
  
#include <avr\io.h>
+
= Downloads=
#include "stdutils.h"
+
Download the complete project folder from the below link:
#include "delay.h" //User defined library which contains the delay routines
+
https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip<br>
  
  
#define LedOn 0xFF
 
#define LedOff 0x00
 
  
/* start the main program */
+
Have a opinion, suggestion , question or feedback about the article let it out here!
void main()
+
{{DISQUS}}
{
+
  /*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);
+
  }
+
  }
+
</syntaxhighlight>
+
 
+
=Video Tutorial=
+
For those of you, who would like to watch instead of read we have made a video with all the gyan.
+
<br>
+
{{#ev:youtubehd|-lNAmSNV2-Q|640}}
+

Latest revision as of 11:18, 19 April 2016


This is the first tutorial with AVR where we will get hands on. 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.


Register Configuration

Please refer the below tutorial for basics of GPIO register configuration.

Code

Below points needs to be considered for this example.

  • Include the io.h file as it has the definitions for all the PORT registers.
  • Include delay.h file to use the delay functions.
  • Configure the PORT as Output before writing any data to PORT pins.

Blink Leds

Led Blinking Wiring Diagram

Blink bb.png


Explore Ultra AVR Dev Kit

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.

0Blinky AVR.gif

Video Tutorial

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


Downloads

Download the complete project folder from the below link: https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip


Have a opinion, suggestion , question or feedback about the article let it out here!