Passing analog pin as argument

Hi so ive created a class called Motor to drive stepper motors for my specific purposes and im trying to make it do as much of the work as possible. the idea is to instantiate the class with a couple of parameters for the enable, direction and step pin numbers and from there it will make the pins outputs and keep them inside the class. makes for clean code when separated to different files. The problem is when i try to pass A8 for the first argument...it complains it doesnt recognise it. i assume it has something to do with the fact the declaration of the integer is sitting in a different file and arduino doesnt know how to deal with that? Any ideas?? :cold_sweat:

Main ino file:

void setup()
{
    motor.init(A8, 48, 46);
}

Motor.h:

class Motor
{
 protected:

 public:
void init(int enablePin, int directionPin, int stepPin);
}

Motor.cpp:

void Motor::init(int enablePin, int directionPin, int stepPin)
{
    pinMode(enablePin, OUTPUT);
    pinMode(directionPin, OUTPUT);
    pinMode(stepPin, OUTPUT);

    digitalWrite(enablePin, LOW);
}

Nope, it knows damn well how the handle analog pins. That’s because the compiler will just swap them for there number before compiling.

Problem is, you pass A8 and you have probably the board set to Uno. And yeay, A8 does not exist on an Uno :wink:

Unless that is a contrived example, passing arguments to the init() method that does not store them in member fields means that you'll need to pass the same numbers to other functions that actually need to make the stepper step, etc.

septillion! thank you so much for pointing out my stupidity :sweat_smile: ...i didnt realise that i changed arduinos between noticing the problem and testing another piece of code haha so i declaired it before passing it and it eliminated the error then changed to mega and didnt realise that would solve the problem...and thanks PaulS! Noted!