2
$\begingroup$

I'm very new with Arduino and Adafruit and I'm trying to get a DC motor running with my Adafruit Motor Shield V2.3, but it's not running. I have connected the motor to the right terminal (M3). I'm following the Adafruit website guide. Does anyone know what I'm doing wrong?

Here is the Arduino and Motor Shield:

enter image description here

And here is my code:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *myMotor = AFMS.getMotor(3);

void setup()
{
  AFMS.begin();
  myMotor->setSpeed(255);
}

void loop()
{
  myMotor->run(FORWARD);
  delay(2000);
  myMotor->run(BACKWARD);
  delay(2000);
  myMotor->run(FORWARD);
  delay(2000);
  myMotor->run(RELEASE);
  delay(1000);
}

The code uploads with no errors but nothing happens after that.

$\endgroup$
  • 1
    $\begingroup$ connect the motor to the battery directly $\endgroup$ – jsotola Nov 24 '19 at 22:18
  • $\begingroup$ It is hard to know what is missing. I recommend checking on the library itself and see all the pins definitions and see that everything is well declared and debug the library itself as it might have something wrong. Maybe the motor is not 3 but 2 or 1. $\endgroup$ – jdios Nov 25 '19 at 21:06
0
$\begingroup$

To quote Adafruit:

You cannot power motors from a 9V battery. You must use AA batteries or a lead acid battery for motors.

You can grab a decent SLA (Sealed Lead Acid) battery by grabbing an alarm battery from any battery store for a relatively decent price (or an online retailer). Alternatively you could get an AA battery holder that lets you put several AA batteries in series.

The reason why a 9V battery won't work is because 9V batteries are chemically incapable of providing the inrush current required to start a motor. The 9 volt battery can be used to power the arduino through the power jack since it requires little current to function.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.