A5 on mega board can't be used as digital output?

Hello everybody,

I'm newbie on arduino (not on embedded programming) and for one project I'm trying to use pin A5 on mega board as digital output but it seems that it doesn't work.

here the sketch:
void setup() {
// put your setup code here, to run once:
pinMode(A5,OUTPUT);
pinMode(A0,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(A5,HIGH);
digitalWrite(A0,HIGH);
delay(5000);
digitalWrite(A5,LOW);
digitalWrite(A0,LOW);
delay(5000);
}

Pin A0 is well used as digital pin but not A5. I tried with a second mega board and have exactly the same problem.

Why?

Thanks

Oli

The description of the MEGA says that it has 54 digital I/O pins. Those would be Pins 0 through 53. The description doesn't mention being able to use the analog input pins for digital I/O (and neither does the UNO documentation). However, looking in the Arduino 1.6.8 core sources it looks like the analog pins (A0-A15) ARE supported as digital I/O pins. I don't know why it isn't working for you.

Note: On the small Arduinos based on the SMD version of the ATmega328P there are often two additional analog input pins: A6 and A7. Those two pins ARE NOT CAPABLE of digital I/O. There is no digital I/O hardware sharing those two pins and they can only act as inputs to the A/D multiplexer.