Moderators: adafruit_support_bill, adafruit
adafruit_support wrote:You have one of the motor leads connected to ground. The H-bridge circuit cannot reverse the motor if one of the leads is connected to ground.
Connect the motor leads to the two terminals of M2 and it should work for you.
When I use 1 ground and 1 Motor 1 the motor rotates constantly in one direction,
the voltage across both M1 leads is 0, but across 1 M1 and ground is 12 V which is what I applied.
The sketch I am running is posted at the beginning of the thread.
#include <AFMotor.h>
AF_DCMotor motor(2);// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
// turn on motor
motor1.setSpeed(200);
motor2.setSpeed(200);
motor3.setSpeed(200);
motor4.setSpeed(200);
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
void loop()
{
uint8_t i;
Serial.print("tick");
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
for (i=0; i<255; i++)
{
motor1.setSpeed(i);
motor2.setSpeed(i);
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--)
{
motor1.setSpeed(i);
motor2.setSpeed(i);
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
Serial.print("tock");
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
for (i=0; i<255; i++)
{
motor1.setSpeed(i);
motor2.setSpeed(i);
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
for (i=255; i!=0; i--)
{
motor1.setSpeed(i);
motor2.setSpeed(i);
motor3.setSpeed(i);
motor4.setSpeed(i);
delay(10);
}
}
Return to Other Arduino products from Adafruit
Users browsing this forum: ArekKindAcere and 5 guests