#include <MyStepper.h>
int stepperPins[4] = {8,9,10,11};
MyStepper myStepper(stepperPins);
EDIT: both loop and setup are empty, just want to create this object succesfuly
yet I get this problem:
C:\Users\User\Documents\Arduino\libraries\MyStepper\MyStepper.cpp: In constructor 'MyStepper::MyStepper(int*, bool, int)':
C:\Users\User\Documents\Arduino\libraries\MyStepper\MyStepper.cpp:25:13: error: incompatible types in assignment of 'int*' to 'int* [4]'
this->_pins=pins;
^
I don't understand. I'm passing an array of size 4, why does it get it as just an int?
AWOL: int* _pins[4];An array of four pointers to int.
Still don't get it.
Tried to change in the arduino code to:
MyStepper myStepper(stepperPins[4]);
and in the cpp& header to:
MyStepper::MyStepper(int* pins[4])
Edit:
with no success
C:\Users\User\Documents\Arduino\libraries\MyStepper\MyStepper.cpp: In constructor 'MyStepper::MyStepper(int**, bool, int)':
C:\Users\User\Documents\Arduino\libraries\MyStepper\MyStepper.cpp:25:13: error: incompatible types in assignment of 'int**' to 'int* [4]'
this->_pins=pins;
^
A great answer for the four values stored in the array stepperPins. But I did not ask about the values stored in the array. I asked about the array itself.
Another way to word the question: Why are you storing the four pin numbers in an array?
AWOL: MyStepper myStepper(stepperPins[4],true,0);What you're trying to do there is pass the fifth element of a four element array.
Put the class code aside, and get comfortable with arrays and pointers.
Hint: the name of an array is a pointer to its first element, and the first element has an index of zero.
At first I was somewhat upset with you. But then I did what you told me to, I re-read the array
guide on cplusplus and changed what it took and it works again now.
So thank you. Really.
So if I ever decide to change it (and I might need to, it's apart of a bigger project), I know where to access it. I also don't want to use 4 integers for code visibility reasons.
But it works now. Thanks for making time for me!