Hi
As you all well aware Arduino UNO A0 pin IDE is 14. So what is the IDE number for Arduino MEGA A0 pin
Please advice
Hi
As you all well aware Arduino UNO A0 pin IDE is 14. So what is the IDE number for Arduino MEGA A0 pin
Please advice
From the pins_arduino.h file in ...\arduino-1.8.5\hardware\arduino\avr\variants\mega
#define PIN_A0 (54)
#define PIN_A1 (55)
#define PIN_A2 (56)
#define PIN_A3 (57)
#define PIN_A4 (58)
#define PIN_A5 (59)
#define PIN_A6 (60)
#define PIN_A7 (61)
#define PIN_A8 (62)
#define PIN_A9 (63)
#define PIN_A10 (64)
#define PIN_A11 (65)
#define PIN_A12 (66)
#define PIN_A13 (67)
#define PIN_A14 (68)
#define PIN_A15 (69)
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
static const uint8_t A8 = PIN_A8;
static const uint8_t A9 = PIN_A9;
static const uint8_t A10 = PIN_A10;
static const uint8_t A11 = PIN_A11;
static const uint8_t A12 = PIN_A12;
static const uint8_t A13 = PIN_A13;
static const uint8_t A14 = PIN_A14;
static const uint8_t A15 = PIN_A15;
But why? You can always use Ax notation even if you are referring to a the digital function of the pin.
pinMode(A0, OUTPUT);
// or
boolean value = digitalRead(A0);
Thanks for the reply
I checked this PDF which do not have it
http://marcusjenkins.com/wp-content/uploads/2014/06/mega2.pdf
Thanks again
Just FYI. The Ax notation is translated to the pin numbers in the wiring_analog.c file in ...\arduino-1.8.5\hardware\arduino\avr\cores\arduino on my system running ver IDE 1.8.5.
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
groundFungus:
Just FYI. The Ax notation is translated to the pin numbers in the wiring_analog.c file in ...\arduino-1.8.5\hardware\arduino\avr\cores\arduino on my system running ver IDE 1.8.5.#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
That code translates from pin number to analog channel number so that the following lines of code are equivalent:
analogRead(54) // using digital style Arduino pin number
analogRead(0); // using analog channel number
The Ax notation is translated in pins_arduino.h, as you already explained.
Although you can use Ax notation, pin number, or channel number with the analog functions, my opinion is that it's best practices to always use the pin names as written on the silkscreen on the board, which is most common in the Arduino world, most consistent (because you can't use analog channel number with the non-analog functions) and therefore least confusing. That does break down a bit with the Nano, which has the digital pins marked as Dx, even though you can't use Dx notation with the Nano, but luckily the other Arduino boards are not marked this way.