Hey GUYS:) I just got the SeeedStudio MotorShield 2.0, and i haven't quite figured it out. I want to run two 7.5 volt dc motors, how would I do this? Also, what would be some syntax suggestions for say, a small car that goes forward at the push of a button?
Have you seen this?
yes, however it doesnt explain how to run two motors
I found this in example within the library download..
// Demo function:The application method to drive the DC motor.
// Author:Frankie.Chu
// Date:20 November, 2012
#include "MotorDriver.h"
void setup()
{
/*Configure the motor A to control the wheel at the left side.*/
/*Configure the motor B to control the wheel at the right side.*/
motordriver.init();
motordriver.setSpeed(200,MOTORB);
motordriver.setSpeed(200,MOTORA);
}
void loop()
{
motordriver.goForward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goBackward();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goLeft();
delay(2000);
motordriver.stop();
delay(1000);
motordriver.goRight();
delay(2000);
motordriver.stop();
delay(1000);
}
Looks to me like two motors..
Pins used: 8..13
#define MOTORSHIELD_IN1 8
#define MOTORSHIELD_IN2 11
#define MOTORSHIELD_IN3 12
#define MOTORSHIELD_IN4 13
#define SPEEDPIN_A 9
#define SPEEDPIN_B 10
Okay... But when i plug in the motors, only one runs, and the other erratically spasms every once in a while?
Btw im using 2 7.5v Super High-Speed motors Radioshack #273-0046
Also, Sorry, Im just beginning arduino, but what are those pins You listed at the bottom? Also, I just plugged the motors into the shield, with motor 1 in OUT1 and OUT2, and moter 2 in OUT3 and OUT4. Do i need to worry about positive or negative? If so, Which OUTputs to use?
Your connections seems right
Try this: (no library at all..)
#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
}
Will try, Thanks:)
Okay, so i ran the sketch, and it ran the motor in 1 and 2, but not the one in 3 and 4? If you need any more details i can specify.
- check jumpers... AND motors!
- check our Arduino - pins 8..13
With a multimeter: check that pins 8 & 12 shows 5V.. and pins 11 &13 -> 0V (LOW)
Pins 9&10 (PWM) should 'confuse' your meter (jumpy readings)
..
found this link (similar to my code)
Motor_Shield/Motor_shield_demo_code.pde at master · Seeed-Studio/Motor_Shield · GitHub