I often see code like this:
const int piezo = A0; const int sensorPin = A1;
From my understanding, an int variable can hold things like -123, 0, 1, 456, etc.
How can A0 or A1 be an int?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
The board definition (pins_arduino.h) has this:
static const uint8_t A0 = 14; static const uint8_t A1 = 15; static const uint8_t A2 = 16; static const uint8_t A3 = 17; static const uint8_t A4 = 18; static const uint8_t A5 = 19; static const uint8_t A6 = 20; static const uint8_t A7 = 21;
Since A0 is a constant variable equal to 14, if you assign that to a variable, it just assigns 14.
In other words:
A = 14. B = A. Therefore B = 14.
They are defined in the Arduino libraries, and the Arduino libraries will translate them into the appropriate pins and registers before they are used. But in the meantime they're numbers.