Motor Shield v1.0 cant work with servo.

Hi, I have a problem. I am trying to connect a servo to an arduino with Motor Shield V1.0
I tried both analog and digital pins, but calling Servo::attach method for any servo makes motor shield unworking.
Leds still work, but motors woun’t move.
Here is the code.
Am I wrong or is it Motorr Sheld problem?

[code]#include <Servo.h>

#define DEBUG_ENABLED 1

/////////////////////
//MOTOR CONTROLS/////
const int pinI1=8;
const int pinI2=11;
const int speedpinA=9;
const int pinI3=12;
const int pinI4=13;
const int speedpinB=10;
const int spead =127;
/////////////////////
Servo neck;
Servo grabber;
char sensorPos = 0;
char command = ‘H’;
int motorState = ‘H’;
int systemState = 0;
const int pingPin = 4;
boolean grabbed;

//////////////////////
////////BODY//////////
//////////////////////

void setup()
{
//neck.attach(3);
grabber.attach(A4);
pinMode(pinI1,OUTPUT);
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);

Serial.begin(9600);
//pinMode(bt_RX, INPUT);
//pinMode(bt_TX, OUTPUT);

setupBlueToothConnection()
grab(false);
grabbed = false;
}

void loop()
{
if(Serial1.available())
{
command = Serial1.read();
switch(command)
{
case ‘F’:
motorState = ‘L’;
break;

  case 'B':
  motorState = 'R';
  break;

  case 'L':
  motorState = 'F';
  break;

  case 'R':
  motorState = 'B';
  break;

  case 'H':
  motorState = 'H';
  break;
  /*
  case 'A':
  Serial1.println("Autopilot Mode!");
  systemState = 1;
  break;
  
  case 'a':
  Serial1.println("Manual Operation!");
  systemState = 0;
  motorState = 'H';
  break;
  */
  case 'S':
  Serial1.println("Scanning...");
  //systemState = 2;
  break;
  
  case 's':
  Serial1.println("Scanner Stopped.");
  //systemState = 0;
  break;
  
  case 'G':
  grabbed = !grabbed;
  grab(grabbed);
  Serial1.print("Grab");
  break;
  
  case '+':
  delay(2000);
  Serial1.print("Connected!");
  Serial1.flush();
  
  default:
  break;
}

}

switch (systemState)
{
case 0:
switch (motorState)
{
case ‘F’:
forward();
break;

  case 'B':
  backward();
  break;

  case 'L':
  left();
  break;

  case 'R':
  right();
  break;

  case 'H':
  halt();
  break;
}
break;

case 1:
//autoAvoid();
break;

case 2:
for(sensorPos = 0; sensorPos < 180; sensorPos++)
{
  neck.write(sensorPos);
  long s = readRange();
  s = (s/180) * 100;
  String message = "[" + (String)sensorPos + " " + (String)s + "]";
  Serial1.println(message);
}
break;

}
//Serial1.flush();
}
[/code]

void forward() { analogWrite(speedpinA,spead);//input a simulation value to set the speed analogWrite(speedpinB,spead); digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise digitalWrite(pinI3,LOW); digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise digitalWrite(pinI1,HIGH); } void backward()// { analogWrite(speedpinA,spead);//input a simulation value to set the speed analogWrite(speedpinB,spead); digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise digitalWrite(pinI3,HIGH); digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise digitalWrite(pinI1,LOW); } void left()// { analogWrite(speedpinA,spead);//input a simulation value to set the speed analogWrite(speedpinB,spead); digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise digitalWrite(pinI3,LOW); digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise digitalWrite(pinI1,LOW); } void right()// { analogWrite(speedpinA,spead);//input a simulation value to set the speed analogWrite(speedpinB,spead); digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise digitalWrite(pinI3,HIGH); digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise digitalWrite(pinI1,HIGH); } void halt()// { digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor. digitalWrite(speedpinB,LOW); } void grab(boolean g) { if(g) { grabber.write(90); } else { grabber.write(1); } }

I actually made changes to Example code of the shield, this is not working as well.

[code]#include <Servo.h>

//. Motor driver shield- 2012 Copyright © Seeed Technology Inc.
//
// Original Author: Jimbo.we
// Contribution: LG
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor
Servo myservo;

void setup()
{
pinMode(pinI1,OUTPUT);
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);
myservo.attach(A4);
}

void forward()
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
digitalWrite(pinI3,LOW);
digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
digitalWrite(pinI1,HIGH);
}
void backward()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
digitalWrite(pinI3,HIGH);
digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
digitalWrite(pinI1,LOW);
}
void left()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
digitalWrite(pinI3,LOW);
digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
digitalWrite(pinI1,LOW);
}
void right()//
{
analogWrite(speedpinA,spead);//input a simulation value to set the speed
analogWrite(speedpinB,spead);
digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
digitalWrite(pinI3,HIGH);
digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
digitalWrite(pinI1,HIGH);
}
void stop()//
{
digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
digitalWrite(speedpinB,LOW);
delay(1000);

}

void loop()
{
left();
delay(2000);
stop();
right();
delay(2000);
stop();
// delay(2000);
forward();
delay(2000);
stop();
backward();
delay(2000);
stop();
myservo.write(90);
delay(2000);
myservo.write(1);
delay(2000);
stop();
}[/code]

hey , i can’t see your function of bluetooth

void loop()
{
......
}

Void setupBluetoothConnetion()
{
......
}

And how did you send command to your device? via Arduino IDE monitor or sscom32? you need pay attention to this,because if you send a command “on” via IDE monitor,the length of data is 3, but via sscom, it is 4…and so on

So maybe you can refer to following link,we used wifi wireless(via command) to control other devices
viewtopic.php?f=10&t=4438

Hi, Jacket Chen. I got bluetooth shield there, it is working, and in the second post I showed that this shield refuses to work with servo, by modifying example code by adding servo. No serial connection used there.
I think it is internal conflict between servo library and this shield :confused:
Bluetooth connection setting itself up by starting Serial1 and sending bunch of AT commands, nothing important. And again Servo makes examples unworking too.

Maybe you need post all codes here…i am not sure whether you have posted a completed code…