Issue with Seeed Studio Motor Shield V2.0 and Arduino UNO

Hi,

I created a video to illustrate my issue, you can find it here: https://www.youtube.com/watch?v=Cx_q6UYMlP8

I’m failing to make an Arduino UNO work with a Seeed Studio Motor Shield V2.0 to control a pair of Geeetech Smart Car Tire/Wheel with DC Gear Motor

I tried using a 9V/170mA battery and a 12V/500mA power adapter. The motor specs are:

Parameter Operating voltage: 3V ~ 12V DC (recommended value is 6 ~ 8V)
Load current: 70mA (250mA MAX)

I don’t think the problem is code related, since I see the LED indicators show the activity expected, as you can see on the video.

You can find my code below based on a similar post in the forum. I also tried to make it run with the provided example that includes the library on the wiki with the same results.

Thanks in advance for any help,

Alejandro


#define M1   8
#define M2   11
#define M3   12
#define M4   13
#define SPA   9
#define SPB   10

int i;

void setup()
{
  for (i=8; i<14; i++) pinMode(i,OUTPUT);
}

void loop()
{
  digitalWrite(M1,HIGH);  // direction motor 1
  digitalWrite(M2,LOW);
  digitalWrite(M3,HIGH);  // direction motor 2
  digitalWrite(M4,LOW);

  analogWrite(SPA,130); // 50% to motor 1
  analogWrite(SPB,192); // 75% to motor 2
  delay(1000);
  for (i=130; i>0; i--)
  {
     analogWrite(SPA,i); // reduce speed Motor 1
     delay(50);
  }
  digitalWrite(SPB,LOW); // stop motor 2
  delay (3000);  // wait - then repeat
}

Hi,

The problem is due to a small bug in your code.It uses variable “i” in both setup and loop which causes the conflict.
Please modify the following lines in your code.

[code]int i,j;

void setup()
{
for (j=8; j<14; j++) pinMode(j,OUTPUT);
}[/code]

Thanks and Regards