Help on RC car project compiling

Hello,

when trying to compile the sketch, I get an error message saying

C:\Users\markr\Documents\Arduino\sketch_jan03c\sketch_jan03c.ino: In function 'void right()':

sketch_jan03c:64:10: error: request for member 'getStepper' in 'motor2', which is of pointer type 'Adafruit_StepperMotor*' (maybe you meant to use '->' ?)

   motor2.getStepper(400, 2);

          ^

sketch_jan03c:65:10: error: request for member 'run' in 'motor2', which is of pointer type 'Adafruit_StepperMotor*' (maybe you meant to use '->' ?)

   motor2.run(FORWARD)

          ^

exit status 1
request for member 'getStepper' in 'motor2', which is of pointer type 'Adafruit_StepperMotor*' (maybe you meant to use '->' ?)

Any help would be appreciated!

Code:

#include <AFMotor.h>
#include <Adafruit_PWMServoDriver.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_StepperMotor *motor2 = AFMS.getStepper(400, 2);

AF_DCMotor motor1(1); 

void setup() { 
     
  Serial.begin(9600);
  
  AFMS.begin();
  
  motor2->setSpeed(10);
  
}


void loop() {
  if(Serial.available() > 0){  
    switch(Serial.read()){
    case 'F':  
      forward();
      break;
    case 'B':  
       back();
      break;
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    }
  } 
}

void forward()
{
  motor1.setSpeed(255);
  motor1.run(FORWARD);
}

void back()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD);
}

void left()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD);
  motor2.getStepper(200, 2);
  motor2.run(BACKWARD)
}

void right()
{
  motor1.setSpeed(255);
  motor1.run(FORWARD);
  motor2.getStepper(200, 2);
  motor2.run(FORWARD)
}

It would be a good idea to study the examples and documentation that come with the libraries. You are misusing the .getStepper() function.

Because your code contains no comments and in addition has syntax errors, it is hard to know what you are trying to do with it.