Adafruit Motorshield V2 Arduino Android App

Hi,

I'm new to arduino, and want to start with a RC car project.

However, i have not a good computer, so now i use the arduino android app to write and upload my code. So far, so good.

i've bought the motorshield V2 , but it keeps returning compile errors, i have installed the files correctly,

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <utility/Adafruit_MS_PWMServoDriver.h>
    
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Adafruit_DCMotor *M1 = AFMS.getMotor(1);
Adafruit_DCMotor *M2 = AFMS.getMotor(2);
Adafruit_DCMotor *M3 = AFMS.getMotor(3);
Adafruit_DCMotor *M4 = AFMS.getMotor(4);

int CMD_Stop = 1;
int CMD_Forward = 2;
int CMD_Reverse = 3;
int CMD_Left = 4;
int CMD_Right = 5;

void setup() {
  AFMS.begin();  
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  M1->setSpeed(150);
  M1->run(FORWARD);
  //// turn on motor
  M1->run(RELEASE);
}

int GetCommand(){
    return CMD_Forward;    
}



void loop() {
  uint8_t i;
  int cmd;
    
  cmd = GetCommand();
    
  if (cmd = CMD_Forward){  
     M1->run(FORWARD);
         for (i=0; i<255; i++) {
         M1->setSpeed(i);  
         delay(10);
         }
         for (i=255; i!=0; i--) {
         M1->setSpeed(i);  
         delay(10);
          }
  }
 

  M1->run(RELEASE);
  delay(1000);
}

I've changed it a bit, but still I think it should compile. Also the origional example, won't compile.

The files are located at this location:

internal storage/ArduinoDroid/Libraries/Adafruit_Motor_Shield_V2_Library

I get a fatal compile error it says the Adafruit_MS_PWMServodriver.h not excist, but when i look at the librarys location it Does excists...

Can anyone advice me? I'm a bit stuck, and really want the motorshield to function... Thanks in advance!

I have also started a topic at
https://forums.adafruit.com/viewtopic.php?f=25&t=127863&p=636979#p636979

Did you by chance leave the "master_" at the beginning of the folder name after removing it from the archive? I've done that before with libraries with similar results.

Thanx for the reply. I don't know what you exactly mean,

But i have donwload a Adafruit Motor Shield V2 Master file, and unzipped it and installed it. However deleting this does not help. Tried to compile the master file and the normal Adafruit Motorshield file, both don't work.

Try downloading the library from here.

Extract the archive and copy Adafruit_Motor_Shield_V2_Library to your "library" folder, after removing "-master" off the end of the folder that's in that archive. Close and reload the arduino IDE and see if it compiles. There was an old and new library and that may be the problem.

Tried it in exactly the same order...

Also reainstalled it, including the 'master' library. Then removed the -master.

But all without succes..

Not sure why. I tried it and the first install, I got the same error you got. Then looked deeper into it, got the library that I just linked to, copied like I mentioned to you, and it then compiled fine.

Maybe someone else can jump in with ideas, or post a question at the Adafruit discussion forum.

i have already opened a topic at adafruit.

I use the android app, perhaps this makes any difference? Or are you using this app too?

No I'm not using the android app - that "could" be the difference. Sorry I couldn't help.

Okay no problem, thanks for trying..

Perhaps there are others who can help me out?

If you still haven't found a way to make the library work, there "is" a "hack" you could do if you can find no other way, but it takes a little work. Remove all the files from the library and put them into your application folder so that they load with the project (will load in separate tabs), then reference the header files with quotation marks instead of like with #include <... .h>. You'll also likely need to put the files from the "utility" folder into the app folder as well and reference them in the same way. You may also need to go into some of those files and change the way they reference the other files in the same way to - replace #include <... .h> with #include "... .h"