Mega2560 digital pins

Has anyone tried using analog inpits as digital pins? I know you can use A0-A5 as pin 14-19. But how is it with the mega?
I searched the forum and there was a topic about this but i didn't get an answer

Thank you!

Tady:
Has anyone tried using analog inpits as digital pins? I know you can use A0-A5 as pin 14-19. But how is it with the mega?
I searched the forum and there was a topic about this but i didn't get an answer

Thank you!

Your are wrong, Pin 14 is not A0,

If you want to treat an Analog pin as digital; It is a simple as:

pinMode(A0,OUTPUT);
digitalWrite(A0,LOW);
digitalWrite(A0,HIGH);
pinMode(A0,INPUT);
char c = digitalRead(A);

The Analog pins an a Mega are Digital pins that Also Do Analog Input.

Chuck.

A0 to A5 are to 14 to 19 on the 328, which is what I think the OP intended.

On the Mega, I think 54 to 69 can be used.

A0 to A5 are to 14 to 19 on the 328, which is what I think the OP intended.

On the Mega, I think 54 to 69 can be used.

void setup(){
  pinMode (54, INPUT);
}
void loop(){
}

CrossRoads:
A0 to A5 are to 14 to 19 on the 328, which is what I think the OP intended.

On the Mega, I think 54 to 69 can be used.

void setup(){

pinMode (54, INPUT);
}
void loop(){
}

Why would you want to use 54 instead of A0?

the compiler does the conversion, so there is no runtime penalty, and it is less error prone?

Chuck.

So it is possible to get 69 digital i/o pins in the mega board!
Im waiting for my mega2560 board . as soon as i get it i will test. Thank you!

CrossRoads:
A0 to A5 are to 14 to 19 on the 328, which is what I think the OP intended.

On the Mega, I think 54 to 69 can be used.

Yep. Pin 54 is A0, (in the same position as A0 on the Uno, next to Vin) and pin 69 is A15.
That caught me out at first too, as I expected A0 to be pin 14 on the Mega as well as the Uno.