I was working with the Motorshield V2 and this sample code. I don't understand the -> symbol as in mystepper1->onestep. I looked in Arduino reference but could not find an explanation. Could someone explain or point me in the right direction?
// wrappers for the first motor!
void forwardstep1() {
myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, SINGLE);
}
// wrappers for the second motor!
void forwardstep2() {
myStepper2->onestep(FORWARD, DOUBLE);
}
void backwardstep2() {
myStepper2->onestep(BACKWARD, DOUBLE);
Thanks
Motor shield demo code question
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88152
- Joined: Sat Feb 07, 2009 10:11 am
Re: Motor shield demo code question
AFMS.getStepper returns a pointer to a stepper motor object.
The "->" operator is the pointer dereference operator. To perform an operation using a pointer to a stepper motor, you need to use the "->" operator as in:
Code: Select all
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
http://www.cplusplus.com/doc/tutorial/pointers/myMotor->step(100, FORWARD, SINGLE);
Please be positive and constructive with your questions and comments.