0

I am writing a code for an automatic garden, and for this, I will use an array of sensors. I want to represent each plant as a class, and so one of the private variables will then be the sensorID, the name of the input on the analog inputs. But these are called 'A0' 'A1' and so forth, so I am wondering what datatype they are?

class Plant{
private:
String name;
??? sensorId;
...
public:
readSensor(??? sensorId);
...
};

I want to standardize this so I don't have to physically write 'A0' or 'A1' each time I need to read the sensor.

  • they are mapped to bytes in arduino – dandavis Jun 14 '17 at 16:23
2

They're uint8_t:

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;

Those are defined in the pins_arduino.h file in the board's variant folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.