0

Adafruit Motor Drive V2.3 - Two DC motors does not activate
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Motor Drive V2.3 - Two DC motors does not activate

by yoitsK on Sun Dec 24, 2017 10:31 am

Hello,

I'm having issue with the two DC motors that are connected to the Adafruit Motor Drive V2 and Arduino Uno. The issue is that two DC motors does not activate at the same time. One is delay by millisecond than the other one. I've attached the code that I started writing on the Arduino IDE. Please let me know if I would need changes on the code. Also, is it necessary to do calibration of the two DC motors so it will activate at the same time?
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_DCMotor *MotorLeft = AFMS.getMotor(1);
Adafruit_DCMotor *MotorRight = AFMS.getMotor(2);

void setup() {
  Serial.begin(9600);

  AFMS.begin();
 
  MotorRight->setSpeed(0);
  MotorRight->run(FORWARD);
  MotorRight->run(RELEASE);
    MotorLeft->setSpeed(0);
    MotorLeft->run(BACKWARD);
    MotorLeft->run(RELEASE);
}

void loop() {
  uint8_t i;

  MotorRight->run(FORWARD);
    MotorLeft->run(BACKWARD);
  for (i=0; i<255; i++) {
    MotorRight->setSpeed(i);
      MotorLeft->setSpeed(i); 
    delay(10);
  }
  for (i=255; i!=0; i--) {
    MotorRight->setSpeed(i);
     MotorLeft->setSpeed(i);   
    delay(10);
  }
    MotorRight->run(RELEASE);
      MotorLeft->run(RELEASE);
    delay(10);

  MotorRight->run(BACKWARD);
    MotorLeft->run(FORWARD);
  for (i=0; i<255; i++) {
    MotorRight->setSpeed(i);
      MotorLeft->setSpeed(i); 
    delay(10);
  }
  for (i=255; i!=0; i--) {
    MotorRight->setSpeed(i);
      MotorLeft->setSpeed(i);
    delay(10);
  }
}

yoitsK
 
Posts: 18
Joined: Thu Nov 09, 2017 5:10 pm

Re: Adafruit Motor Drive V2.3 - Two DC motors does not activ

by adafruit_support_bill on Sun Dec 24, 2017 11:29 am

Please do not double-post. You have an identical topic here: viewtopic.php?f=31&t=128464

adafruit_support_bill
 
Posts: 69809
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.