2011:arduino_to_avr_pin_mapping
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
2011:arduino_to_avr_pin_mapping [2011/08/07 10:15] – tomgee | 2011:arduino_to_avr_pin_mapping [2011/10/14 09:34] (current) – tomgee | ||
---|---|---|---|
Line 4: | Line 4: | ||
{{: | {{: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Using Port C as digital output (Read 1072 times) | ||
+ | |||
+ | |||
+ | Using Port C as digital output | ||
+ | 03.02.2010 at 16: | ||
+ | |||
+ | It took me a bit of time to extract this info from the docs and the board itself, so I thought I'd post it here so any searchers in the future will get there quicker. | ||
+ | |||
+ | This is for the Duemilanove | ||
+ | |||
+ | // | ||
+ | |||
+ | In your setup: | ||
+ | // Turn analog inputs to digital outputs | ||
+ | | ||
+ | |||
+ | |||
+ | In your loop: | ||
+ | | ||
+ | // ...etc... | ||
+ | | ||
+ | Back to top | ||
+ | |||
+ | |||
+ | View Profile | ||
+ | Groove | ||
+ | God Member | ||
+ | ***** | ||
+ | |||
+ | Re: Using Port C as digital output | ||
+ | Reply #1 - 03.02.2010 at 16: | ||
+ | I don't think there' | ||
+ | Back to top | ||
+ | |||
+ | |||
+ | View Profile | ||
+ | TBAr | ||
+ | Senior Member | ||
+ | **** | ||
+ | Offline | ||
+ | |||
+ | |||
+ | |||
+ | Posts: 388 | ||
+ | |||
+ | |||
+ | Re: Using Port C as digital output | ||
+ | Reply #2 - 03.02.2010 at 18: | ||
+ | That's true as long as you initialize the pins to OUTPUT before you use digitalWrite(). | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | That's traditionally done in setup(). | ||
+ | Back to top | ||
+ | |||
+ | |||
+ | View Profile | ||
+ | BenF | ||
+ | God Member | ||
+ | ***** | ||
+ | Offline | ||
+ | |||
+ | Arduino rocks | ||
+ | |||
+ | Posts: 760 | ||
+ | |||
+ | |||
+ | Re: Using Port C as digital output | ||
+ | Reply #3 - 03.02.2010 at 20: | ||
+ | Quote: | ||
+ | // Turn analog inputs to digital outputs | ||
+ | DDRC=0xFF ; // These will be pin numbers 14 .. 19 | ||
+ | |||
+ | The DDRC register determines data direction (input or output) for port-C. | ||
+ | Setting all bits to one (as in your code) will configure the pins for output. It | ||
+ | is not related to switching between analog/ | ||
+ | this). | ||
+ | |||
+ | Port C includes the RESET pin on PC6 and an undefined pin on PC7. PC0 thru PC5 | ||
+ | map to Arduino A0 (14) thru to A5 (19). Forcing RESET to become an output pin | ||
+ | (as would be the case with your statement) | ||
+ | unless the ATmega chip is refused to disable/ | ||
+ | practice to force an undefined pin (A7) to any value - rather you should leave | ||
+ | it as is (DDRC|=0x3f would be ok). | ||
+ | |||
+ | |||
+ | |||
+ | View Profile | ||
+ | oransen | ||
+ | YaBB Newbies | ||
+ | * | ||
+ | Offline | ||
+ | |||
+ | Arduino rocks | ||
+ | |||
+ | Posts: 22 | ||
+ | |||
+ | |||
+ | Re: Using Port C as digital output | ||
+ | Reply #4 - 04.02.2010 at 07: | ||
+ | So, I should actually do: | ||
+ | |||
+ | // Turn analog inputs to digital outputs | ||
+ | | ||
+ | |||
+ | is that right? | ||
+ | |||
+ | I posted this because I could not find any clear examples of using these pins. | ||
+ | |||
+ | And you say: | ||
+ | |||
+ | "PC0 thru PC5 map to Arduino A0 (14) thru to A5 (19)." | ||
+ | |||
+ | which I understand, but what is the advised way of naming these pins. 14 ... 19. I can't find the C define for " | ||
+ | |||
+ | Back to top | ||
+ | |||
+ | |||
+ | View Profile | ||
+ | BenF | ||
+ | God Member | ||
+ | ***** | ||
+ | Offline | ||
+ | |||
+ | Arduino rocks | ||
+ | |||
+ | Posts: 760 | ||
+ | |||
+ | |||
+ | Re: Using Port C as digital output | ||
+ | Reply #5 - 04.02.2010 at 08: | ||
+ | The Arduino way would be as follows: | ||
+ | Code: | ||
+ | |||
+ | pinMode(14, | ||
+ | digitalWrite(14, | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Direct PORT IO is as follows: | ||
+ | Code: | ||
+ | |||
+ | DDRC |= _BV(PORTC0); | ||
+ | PORTC |= _BV(PORTC0); | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Back to top | ||
+ | |||
+ | |||
+ | View Profile | ||
+ | Pages: 1 | ||
+ | Send Topic | Print | ||
+ | Arduino Forum › Hardware › Interfacing | ||
+ | ‹ Previous Topic | Next Topic › | ||
+ | |||
+ | Arduino Forum » Powered by YaBB 2.2.3! | ||
+ | YaBB © 2000-2008. All Rights Reserved. | ||
+ | |||
+ | Valid RSS Valid XHTML Valid CSS Powered by Perl Source Forge | ||
+ | |||
+ | |||
+ |
2011/arduino_to_avr_pin_mapping.1312726552.txt.gz · Last modified: 2011/08/07 10:15 by tomgee