Go Down

Topic: Pin mapping of the Zero/M0 Pro (Read 121 times) previous topic - next topic

dangu

I have been trying to run a sketch written for the Uno on a M0 Pro board and just realized that the pin mappings of the A0-A5 pins are not identical between the two boards. On the link http://playground.arduino.cc/Learning/Pins it says that the mapping of A0 is Pin 14, but on the M0 Pro it is Pin 24.

For me, the code for the Uno:
Code: [Select]

pinMode(14, OUTPUT);
digitalWrite(14, HIGH);   // turn the LED on (HIGH is the voltage level)

has to be changed to
Code: [Select]

pinMode(24, OUTPUT);
digitalWrte(24, HIGH);   // turn the LED on (HIGH is the voltage level)


Maybe it's better to be using the alias for the pins instead. This code also seems to work:
Code: [Select]

pinMode(A0, OUTPUT);
digitalWrte(A0, HIGH);   // turn the LED on (HIGH is the voltage level)


I have been searching for a document describing these mappings for the M0 Pro. Do you know where I can find this? I would then like to update the page http://playground.arduino.cc/Learning/Pins with these mappings.

PaulS

The Arduino team developed aliases for the analog pins being used as digital pins. A0 refers to the first analog pin, regardless of which board. A1 refers to the second pin, regardless of which board. Why not use them?

dangu

Yes, I'm starting to realize that. I have now rewritten my code to instead use the aliases (A0, A1 and so on). Seems like the best suggestion.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy