Motor Shield V2 not working with Arduino Mega 2560 Rev3

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bhatadb
 
Posts: 17
Joined: Thu May 01, 2014 3:46 pm

Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by bhatadb »

I was using the shield with a Uno, and everything worked.

But I got a new Mega 2560 and the motor shield isn't working with it.
[img]
20140813_224322.jpg
20140813_224322.jpg (152.49 KiB) Viewed 501 times
[/img]

[img]
20140813_224333.jpg
20140813_224333.jpg (128.32 KiB) Viewed 501 times
[/img]

I used the DC Motor test from the examples:

Code: Select all

/* 
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2 
---->	http://www.adafruit.com/products/1438
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(2);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  myMotor->setSpeed(150);
  myMotor->run(FORWARD);
  // turn on motor
  myMotor->run(RELEASE);
}

void loop() {
  uint8_t i;
  
  Serial.print("tick");

  myMotor->run(FORWARD);
  for (i=0; i<255; i++) {
    myMotor->setSpeed(i);  
    delay(10);
  }
  for (i=255; i!=0; i--) {
    myMotor->setSpeed(i);  
    delay(10);
  }
  
  Serial.print("tock");

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

  Serial.print("tech");
  myMotor->run(RELEASE);
  delay(1000);
}
Based on what I saw in the forum, someone else also had the same problem back in 2013, but not sure if that was the unified library or not.

What can I do to make this work? I am in the last stage of development of my system, and need the Mega because it has multiple UARTs. Multiple instances of software serial aren't working as I intend them to.

Thanks,
Abhi

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by Franklin97355 »

What do you mean by "not working" does it do anything at all? Does it print the first message?

User avatar
bhatadb
 
Posts: 17
Joined: Thu May 01, 2014 3:46 pm

Re: Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by bhatadb »

Solution:

Connecting the SDA and the SCL ports on the shield with the SDA and SCL ports on the Mega R3 shield makes the shield work.

There are 2 SDA and SCL ports on this board. Are they internally connected?

Thanks,
Abhi

User avatar
bhatadb
 
Posts: 17
Joined: Thu May 01, 2014 3:46 pm

Re: Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by bhatadb »

I am sorry. I meant that the motors don't move. The first message was printing, and I could see the tic and toc show up on the serial port.

Abhi

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by Franklin97355 »

They should be internally but the motor shield, I believe uses A4 and A5 which are not in the same place. I have not looked at the schematics and I don't have a motor shield so I can't be sure. Here is a good reference for you http://pighixxx.tumblr.com/image/93501950885

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2 not working with Arduino Mega 2560 Rev3

Post by adafruit_support_bill »

If you have an R3 Mega, you should not need to change anything. A4/A5 and SDA/SCL are internally connected on the shield.

Make sure that you don't have anything else connected to A4 and A5.
Check your soldering on SDA/SCL. If you post photos of your soldering on the shield, we'll take a look too.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”