How Do I Control Adafruit Motor Shield v2 with Only Digital Output Pins?

I have an Adafruit motor shield v2 (p1438) and am trying to just run wires to it from my Arduino to control 3 DC motors. I already have two shields on my Mega board and just want to write normal code to control the motors, like digitalWrite(2, HIGH) to turn the motor one direction and digitalWrite(3,HIGH) to turn it the other direction. No PWM, just full on/off but with two directions. Can this be done?

I think that every shield has an id to init like this
Adafruit_MotorShield AFMS0 = Adafruit_MotorShield(0x60);
the 0x60 is for the first then 0x61 0x62 and so on.Do you have problem that the arduino program does not work when shield is stacked on top of other shield?

I haven't tried stacking it yet. I have a different motor shield (one that requires you to declare the pins) and an xbee on my Mega board already and don't have room in my robot for a third shield stacked on the Arduino. I looked at the code for the adafruit v2 motor shield though, and it doesn't have you declare pins. It looks like it has a built-in code that would decide for itself which pins to use. Most of the pins that the shield would plug into are already being used, so I'm concerned about compatibility with my current setup.

I've used this shield, you don't declare pins from the Mega but you declare the ones on the shield. All digital and analog pins are available when you stack this shield and it is compatible with the Mega per the FAQ on the adafruit site.

The shield has motor ports to connect your motors(up to 4 dc motors)to and you just declare them as objects and give the port that it is on i.e.. 1,2,3
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
Adafruit_DCMotor *myMotor = AFMS.getMotor(2);
Adafruit_DCMotor *myMotor = AFMS.getMotor(3);

The shield will draw power from the Mega but can be setup with a separate power source.

I wouldn't think it would interfere since you aren't using pins from other I/O devices.

ribbonman:
I've used this shield, you don't declare pins from the Mega but you declare the ones on the shield. All digital and analog pins are available when you stack this shield and it is compatible with the Mega per the FAQ on the adafruit site.

The shield has motor ports to connect your motors(up to 4 dc motors)to and you just declare them as objects and give the port that it is on i.e.. 1,2,3
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
Adafruit_DCMotor *myMotor = AFMS.getMotor(2);
Adafruit_DCMotor *myMotor = AFMS.getMotor(3);

The shield will draw power from the Mega but can be setup with a separate power source.

I wouldn't think it would interfere since you aren't using pins from other I/O devices.

Thanks! That is good to know. I misunderstood how the shield worked. I'll start toying with it now to see if I can fit it inside the robot.

billygoat162:
I have an Adafruit motor shield v2 (p1438) and am trying to just run wires to it from my Arduino to control 3 DC motors. I already have two shields on my Mega board and just want to write normal code to control the motors, like digitalWrite(2, HIGH) to turn the motor one direction and digitalWrite(3,HIGH) to turn it the other direction. No PWM, just full on/off but with two directions. Can this be done?

I think you need to have a good read of the manual and how I2C works.
Your motor shield uses I2C to be controlled.
You need to have a long read of this.

By the looks of it the shield only needs 5V, gnd, SDA and SCL from your Mega board.
Tom... :slight_smile: