0

I'm having issues with how my library variables are interacting with the stepper motor's object declaration. I'm getting a "variable was not declared in this scope" error. Does anyone have any advice? I'll post the link to the branch my code is on. Please forgive the current folder setup in the branch. I'm in the alpha stages of this code.

https://github.com/HullabalooRobotics/Soldering-Machine/tree/testBranch/SolderingMachine

My object creation in the .cpp isn't pulling from the arrays I created in the .h, when I believe it should. I'm open to any and all advice!

1 Answers1

0

In your code

Stepper stepperA(60,_stepperMotorPinA[0], _stepperMotorPinA[1], _stepperMotorPinA[2], _stepperMotorPinA[3]);
Stepper stepperB(60,_stepperMotorPinB[0], _stepperMotorPinB[1], _stepperMotorPinB[2], _stepperMotorPinB[3]);
Stepper stepperC(60,_stepperMotorPinC[0], _stepperMotorPinC[1], _stepperMotorPinC[2], _stepperMotorPinC[3]);
Servo solderServo;

Is a part of the global scope, as such it does not have access to the instances _stepperMotorPin* which are the properties of the instance of your class.

For your code to work properly, you will have to make stepper* instances a part of your class as properties, and initialize them inside a function of the class.

Nitro
  • 1,063
  • 1
  • 7
  • 17
  • Hey Nitro! With this being my first question, I'm happy to see such a quick response. However, being a novice coder, I'm not sure I follow. To be more accurate, I don't follow your second paragraph (I'm sure it's correct, I just need a little more explanation). I tried moving the stepper motor object declaration (I think that's how you say it) to the private section of the SolderingMachine class, but was met with many compile errors. I also tried putting them into the library's constructor, with similar results. What is this about putting them into their own function to initialize them? – Robert Forsyth Mar 08 '19 at 14:18