Pages: [1]   Go Down
Author Topic: Differentiate between A3 and D3 in code  (Read 1114 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This might be a stupid question, but I can't seem to find the answer.

I have a Pro-Mini 16MHz from Sparkfun.  I'd like to use all of the pins, but I'm confused about how I would define the use of both the A3 and D3 pins.  I know I can't just say pin 3 right?

For example:

I can do analogRead(3) and that's A3 right?  Can't I also do digitalRead(3) and that be D3?
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16561
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I can do analogRead(3) and that's A3 right?  Can't I also do digitalRead(3) and that be D3?

Yes, that is correct the analogread and digitalread functions know which pin 3 to use, A3 or D3 respectively.

Lefty

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, that part make sense.  But what if I want to use A3 as a digital IO pin?
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16561
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then you use the following from the Arduion reference section:

"The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5). "

so using:

pinMode(17, INPUT);
val = digitalRead(17);

Will allow the A3 pin to be used as a digital input pin.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sweetness.  Thanks a bunch.  What section was that under?
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16561
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/DigitalRead
Logged

Pages: [1]   Go Up
Jump to: