Go Down

Topic: Adafruit Motor Shield (Read 1 time) previous topic - next topic

I recently purchased the Adafruit Motorshield. It can flawlessly run either motors or servos, but if I try to run the motors (any of the 4 channels) the servos go beserk. Here is my test code:
#include <AFMotor.h>
AF_DCMotor motor(4);

void setup() {


void loop() {

I checked, no bridged pins or the like, all the pins are functioning normally. I am using a Arduino Mega 2560.


Hmmm, looks like it ought to work having looked a bit at the library.  Probably crosstalk or missing ground connection?  Is the power supply powerful enough to run servos and motors?
[ I won't respond to messages, use the forum please ]

The power source is 6x AA batteries.

I tried hooking the servo directly up to pin 13 (which isn't used by the shield), gnd and 5V, and the motor to M4, running off of the seperate power brick, and the servo still had irregular motion. If I wanted to control the Adafruit shield without the AFMotor.h library, I could just use analogWrite for PWM and digitalWrite for direction, right?


You'd have to drive the pins that talk to the shift register with digitalWrite and the 4 PWM pins it uses with analogWrite, yes.  And remember to set them as OUTPUTs.
[ I won't respond to messages, use the forum please ]

I tried setting the pins labeled M# to analog(200), and the direction pins to HIGH. got nothing. How exactly would I do this?

I got the AFMotor library to work. The problem was noise from the motors, and not the library. Thanks for your help!

Go Up