Line 14: Line 14:
  
  
=Hookup=
+
=Register Configuration =
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.
+
Please refer the below tutorial for basics of GPIO register configuration.
==Type 1:Breadboard with Explore AVR 40 Pin Breakout Board with Atmega32==
+
<html>
===Components Used===
+
<ul>
 +
<a href="https://www.exploreembedded.com/wiki/2._AVR_I/O_Register_Configuration">AVR I/O Register Configuration
 +
</a>
 +
</ul>
 +
</html>
  
{| class="wikitable"
+
=Code=
|-
+
Below points needs to be considered for this example.
| 1||
+
* Include the io.h file as it has the definitions for all the PORT registers.
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/avr-mcu-breakout/1-dsc02958.jpg" width="300 px"></html>
+
* Include delay.h file to use the delay functions.
 +
* Configure the PORT as Output before writing any data to PORT pins.
 +
<html>
 +
<script src="https://gist.github.com/SaheblalBagwan/310b1582e0bec2ad28ad.js"></script>
 +
</html>
  
|| AVR 40 pin breakout board with Atmega32<br />
+
==LEDs and Switches Wiring diagram==
[https://www.exploreembedded.com/product/AVR%2040%20Pin%20Breakout%20Board%20with%20Atmega32 Click here to buy from our store]
+
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/fritzing-tutorials_de69ccc2/switch_bb.png" width="670 px"></html>
|-
+
|2||
+
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/breadboard-large/breadboard_large.jpg" width="300 px"></html>
+
  
|| Breadboard <br />
 
[https://www.exploreembedded.com/product/Large%20Breadboard Click here to buy from our store]
 
|-
 
| 3||
 
<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>
 
  
|| Male to Male Jumper Wires <br />
 
[https://www.exploreembedded.com/product/Male%20to%20Male%20Jumper%20Wires%20-%20Pack%20of%2040 Click here to buy from our store]
 
|-
 
  
| 4||
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/led-5mm-red/5mm_red_led.jpg" width="300 px"></html>
 
|| 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]
 
|-
 
  
|| 6||
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/dip-switche-8-position/8-way-dip-switch.jpg" width="300 px"></html>
 
|| DIP Switch - 8 Position <br />
 
[https://www.exploreembedded.com/product/DIP%20Switch%20-%208%20Position Click here to buy from our store]
 
|}
 
  
  
==Wiring diagram==
 
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/fritzing-tutorials_de69ccc2/switch_breadboard_bb.png" width="670 px"></html>
 
  
==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.
 
 
<html>
 
<html>
 
<ul>
 
<ul>
Line 75: Line 53:
 
</html>
 
</html>
  
<html><img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/fritzing-tutorials_de69ccc2/switch_bb.png" width="670 px"></html>
 
 
=Code=
 
<syntaxhighlight>
 
 
/*-----------------------------------------------------------------------------
 
                Program to demonstrate Switches and Leds
 
  -----------------------------------------------------------------------------
 
 
note:
 
1.Leds are  connected to PORTC
 
2.Switches are connected to PORTA
 
 
------------------------------------------------------------------------------*/
 
 
 
/*contains the definition of all ports and SFRs */
 
#include <avr\io.h>
 
#include "stdutils.h"
 
 
#define Switches PINA
 
#define LEDs PORTC
 
 
/* start the main program */
 
void main()
 
{
 
  unsigned char SwitchData;
 
 
  /*Configure the PORTA as I/p to read the switch data */
 
  DDRC = C_PortOutput_U8;
 
  DDRA = C_PortInput_U8;
 
 
  while(1)
 
    {
 
 
 
  /*Read the switch position */
 
  SwitchData =  Switches;
 
 
/*Turn on the respective led depending on Switch position */
 
  LEDs=SwitchData;
 
  }
 
  }
 
</syntaxhighlight>
 
  
 
=Video Tutorial=
 
=Video Tutorial=

Revision as of 15:48, 4 February 2016

Xplore007 (talk) 15:44, 4 February 2016 (IST)


The Rock (1996)

Objective

After blinking the leds, its time control these leds depending on external inputs. In this tutorial we will interface a DIP switch to one of the Port's and display its status on LED's connected to other port.


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.

LEDs and Switches Wiring diagram





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.


Video Tutorial

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