I'm writing a library for Arduino, and I've run into this problem:
I need to create an uint8_t
variable to define an analog pin (Ax
) and I'm not being able to do it in an easy way.
This more or less illustrates my problem, _pin
being an uint8_t
:
sensortemp::sensortemp(int pin) // Constructor
{
// being _pin an uint8_t
// _pin = A0 if pin = 0;
// _pin = A1 if pin = 1;
// etc.
}
The only working solution I've found is one I do NOT want to use...
sensortemp::sensortemp(int pin)
{
if(pin == 0)
_pin = A0;
else if(pin == 1)
_pin = A1;
else if(pin == 2)
_pin = A2;
else if(pin == 3)
_pin = A3
}
I hope someone can help me with this uint8_t
problem :)
Thanks in advance