Motor Shield Programing

I am trying to make Bluetooth Arduino car.I am using a motor shield(https://playground.arduino.cc/Main/AdafruitMotorShield) and a HC-06 Bluetooth shield.Can someone tell me what is wrong with my code.I followed the example from the arduino page(https://playground.arduino.cc/Main/AdafruitMotorShield).But I got ‘motor was not declared in this scope’.

#include <Servo.h>//SERVO library
#include <AFMotor.h>//MOTOR SHIELD library
char data = 0;//BLUETOOTH
char power = 0;
int led1 =14; //FRONT and REAR light
int led2 =2;  //REVERSE light
int led3 =13; //BRAKE light
int horn =15;

// These are used to set the direction of the bridge driver.
#define MOTOR1_A 2
#define MOTOR1_B 3
#define MOTOR2_A 1
#define MOTOR2_B 4
#define MOTOR3_A 5
#define MOTOR3_B 7
#define MOTOR4_A 0
#define MOTOR4_B 6

// Arduino pins for the PWM signals.
#define MOTOR1_PWM 11
#define MOTOR2_PWM 3
#define MOTOR3_PWM 6
#define MOTOR4_PWM 5
#define SERVO1_PWM 10

// Codes for the motor function.
#define FORWARD 1
#define BACKWARD 2
#define BRAKE 3
#define RELEASE 4


// Declare classes for Servo connectors of the MotorShield.
Servo servo_1;


void setup() 
{
 Serial.begin(9600); 
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 servo_1.attach(SERVO1_PWM);

}

void loop() 
{
 data = Serial.read(); 
 if(data == '8' );
 {digitalWrite(led1, HIGH);
 }
 if(data == '9' );
 {digitalWrite(led1, LOW);
 }

 //FRONT and BACK lights turns on and off through bluetooth

 if(data == '0' );
 {
   motor(1, FORWARD, power);
   motor(2,FORWARD, power);
   motor(3,FORWARD, power);
   motor(4,FORWARD, power);
 }
 if(data == '1' );
 
  motor(1, RELEASE, 0);
  motor(2, RELEASE, 0);
  motor(3, RELEASE, 0);
  motor(4, RELEASE, 0);
 }
 //GO FORWARD
 if(data == '2' );
 {
  motor(1, BACKWARD, power);
  motor(2, BACKWARD, power);
  motor(3, BACKWARD, power);
  motor(4, BACKWARD, power);
  digitalWrite(led2, HIGH); 
 }
 if(data == '3' );
 {
  motor(1, RELEASE, 0);
  motor(2, RELEASE, 0);
  motor(3, RELEASE, 0);
  motor(4, RELEASE, 0);
  digitalWrite(led2, LOW);
 }
 //GO BACKWARD
 
 if(data == '4' );
 {
 (power == 64);
 }
 if(data == '5' );
 {
 (power == 128);
 }
 if(data == '6' );
 {
 (power == 192);
 }
 if(data == '7' );
 {
 (power == 255);
 }
 //power control

 if(data == 'a' );
 {servo_1.write(75);  
  delay(500);
  servo_1.write(60);
  delay(500);
  servo_1.write(45);
  delay(500);
  servo_1.write(30);
  delay(500);
 }
  if(data == 'b' );
 {servo_1.write(105);  
  delay(500);
  servo_1.write(120);
  delay(500);
  servo_1.write(135);
  delay(500);
  servo_1.write(150);
  delay(500);
 }
 if(data == 'c' );
 {servo_1.write(90);
 }
 //SERVO control

 
          



}

someone pls help i am a newbie

Your code is very different from that on the page you linked to for the old Motor Shield. You have left out a lot of the code, including the part where function motor() is defined.

I think you may have mixed up several different examples. Are you sure it's the original Mk1 Motor Shield you have. It's very old.

Steve

I didnt use the code the the webpage because it was quite complicating for a starter(not that new)so I used the ones that I used the examples from the library from ADAFRUIT .

The first thing is to sort out what version of the Adafruit Motor Shield you have.

Does it look like this:-

Which is the current version (clearly marked V2.0 on the board).

or does it look like this:-

Which is the original version.

Also you are ending all your if statements with a semi-colon which means instead of only executing the statements in braces if the condition is true they will always be executed:-

This code

 if(data == '0' );                   // <-- this semi-colon makes a lot of difference
 {
   motor(1, FORWARD, power);
   motor(2,FORWARD, power);
   motor(3,FORWARD, power);
   motor(4,FORWARD, power);
 }

Should read:-

 if(data == '0' )                      // Now the statements in braces will only be executed if data==0
 {
   motor(1, FORWARD, power);
   motor(2,FORWARD, power);
   motor(3,FORWARD, power);
   motor(4,FORWARD, power);
 }

Ian