If I want to use the analog pins on MEGA as digital pins, can I do A0, A1 etc.? What about using a number? I'm used to UNO's digital pin 14 is analog pin 0. How are MEGA pins mapped to digital pin numbers? Thanks.
From WProgram.h:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
const static uint8_t A0 = 54;
const static uint8_t A1 = 55;
const static uint8_t A2 = 56;
const static uint8_t A3 = 57;
const static uint8_t A4 = 58;
const static uint8_t A5 = 59;
const static uint8_t A6 = 60;
const static uint8_t A7 = 61;
const static uint8_t A8 = 62;
const static uint8_t A9 = 63;
const static uint8_t A10 = 64;
const static uint8_t A11 = 65;
const static uint8_t A12 = 66;
const static uint8_t A13 = 67;
const static uint8_t A14 = 68;
const static uint8_t A15 = 69;
#else
const static uint8_t A0 = 14;
const static uint8_t A1 = 15;
const static uint8_t A2 = 16;
const static uint8_t A3 = 17;
const static uint8_t A4 = 18;
const static uint8_t A5 = 19;
const static uint8_t A6 = 20;
const static uint8_t A7 = 21;
#endif
Thank you John! Exactly what I was looking for. So for the variables AVR_ATmega1280 and AVR_ATmega2560 are they defined when you select your board to be MEGA?
liudr:
Thank you John! Exactly what I was looking for. So for the variables AVR_ATmega1280 and AVR_ATmega2560 are they defined when you select your board to be MEGA?
Yes.
Thanks! I got a MEGA clone but have not found a project for it yet so don't know much about their pins much.