Motor Shield from SeeedStudios

I am trying to adapt the code to get the Motor Shield working with my Spark Core and Shield Shield.

So far, no luck. I’d appreciate any points in the right direction.
I did try remapping the pins to their counterparts on the Core, but that didn’t seem to work either.

Here is the sample code provided from the manufacturer:

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
 
void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
}
 
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(); 
}

Hi,
Have you tried out the sample code and instructions mentioned here? http://docs.spark.io/#/shields/spark-rc-car-kit

1 Like

No, but I will now. Thanks!

Let me know if you do get it to work. I’ve got a Seeed Studio Motor Shield as well and I can get the Spark to activate the same indicator LEDs on the motor shield as my Arduino Uno, but with the Spark, the motors don’t spin and no voltage is going out of the motor control connections. The LEDs look like they’re a bit dimmer with the Spark, so I’m wondering if the Shield Shield isn’t providing the same amount of power as the Arduino Uno does.

According to the Shield Shield pin mapping page, changing the SEEED Motor Shield example sketch variables to the following should work for the Spark, but I am running into the same issue as mootcycle, the indicator LEDs activate but the motors don’t move or make any noise. I am wondering if maybe the Spark is outputting 3.3v and the motor shield needs 5v. Need to check with a volt meter…

    int pinI1         = D5;    //define I1 interface
    int pinI2         = A5;    //define I2 interface 
    int speedpinA     = D6;    //enable motor A
    int pinI3         = A4;    //define I3 interface 
    int pinI4         = A3;    //define I4 interface 
    int speedpinB     = A2;    //enable motor B
    int speed         = 127;   //define the spead of motor

Did you see if the voltage was the problem? I’d like to know if I can use it with the spark.
It seems like these pins are all digital however.
@bcarroll

Aren’t we supposed to power the motor shield using an external power source?