AVR Programming:
Download
1 / 9

AVR Programming: Digital I/O September 10, 2010 - PowerPoint PPT Presentation


  • 54 Views
  • Uploaded on

AVR Programming: Digital I/O September 10, 2010. What is Digital I/O?. Digital – A 1 or 0 Input – Data (a voltage) that the microcontroller is reading from an external source Output – Data (a voltage) that the microcontroller is setting to be used by an external source.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' AVR Programming: Digital I/O September 10, 2010' - chaney


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

AVR Programming:

Digital I/O

September 10, 2010


What is digital i o
What is Digital I/O?

  • Digital – A 1 or 0

  • Input – Data (a voltage) that the microcontroller is reading from an external source

  • Output – Data (a voltage) that the microcontroller is setting to be used by an external source


Where does this happen
Where does this happen?

  • I/O Ports

  • 6 8-bit I/O ports (A-F)

  • 1 4-bit I/O port (G)

  • Most have an alternate purpose


How do i access these pieces of metal in software
How do I access these pieces of metal in software?

  • They are memory mapped

  • Certain memory addresses are reserved for I/O Registers

  • A few examples (Ports A-D):


Do i need to memorize those addresses
Do I need to memorize those addresses?

No!

#include <avr/io.h>

Each register and bit within it is defined for you

5


How does this look in code
How does this look in code?

//set the bottom three bits of Port A to output

DDRA |= _BV(DDA0) | _BV(DDA1) | _BV(DDA2);

//output high on pins 0 and 2 of port A

PORTA |= _BV(PA0) | _BV(PA2);

//output low on pin 1 of port A

PORTA &= ~(_BV(PA1));

//set Port B to input

DDRB = 0x00;

//read Port B

char x = PINB;


What can we do with this on the robots
What can we do with this on the robots?

Note: Pin 33 and 34 are PG0 and PG1


Stuff to try out
Stuff to try out

  • Reading from the push buttons

    • make sure to enable internal pull up (PORTG |= 3;)

  • Turning on the orbs

  • Rapidly turning the orbs on and off

    • Maybe even in patterns (off off on off off on…)

  • Rapidly switching orb colors

    • e.g. (blue green off blue green off…)

  • Combinations of above

  • You should not need the dragonfly library


Help more info
Help/More Info

Datasheet:

http://www.atmel.com/dyn/resources/prod_documents/doc2467.pdf


ad