Motor Shield kit v2.0 / can't get it to compile!

Our weekly LIVE video chat. Every Wednesday at 8pm ET!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

Hi!

I bought t6his adafruit motor shield kit v2.0 and having trouble compiling it.

hangs up on adafruit_DCmotor *mymotor = ASMF.get Motor(1);

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by adafruit_support_bill »

What code are you trying to compile?
What exactly is the error message?

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

The code is DCMotor Test from libraries that was downloaded from adafruit.

error:
expected constructor, destructor, or type conversion before - token

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

I would like to mention that I soldered the stack address 0x60 on the board,
could this have given me that error?

I'll wait for your answer.

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by adafruit_support_bill »

error:
expected constructor, destructor, or type conversion before - token
That is not a typical error. Post the exact code you are using. Use the '</>' button above and paste your code between the

Code: Select all

 tags.

Also, make sure that you scroll to the top of the error output window and get the first few lines of error messages.  Those are usually the most relevant.

[quote]I would like to mention that I soldered the stack address 0x60 on the board,
could this have given me that error?[/quote]
The stack address does not affect the compile.  You should not have to solder anything for address 0x60:
[quote]
Board 0: Address = 0x60 Offset = binary 0000 (no jumpers required)
Board 1: Address = 0x61 Offset = binary 0001 (bridge A0 as in the photo above)
Board 2: Address = 0x62 Offset = binary 0010 (bridge A1, to the left of A0)
Board 3: Address = 0x63 Offset = binary 0011 (bridge A0 & A1, two rightmost jumpers)
Board 4: Address = 0x64 Offset = binary 0100 (bridge A2, middle jumper)
[/quote]

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

Hi!

Sorry, I don't know what a tag is, I looked it in my Ardunio book, it did not help me.

not sure about </>

I have never coped any thing for forum before..
May need some help there too.

Thanks
Frank G.





/* 
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(1);
// 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);
}
Last edited by adafruit_support_bill on Fri Jun 20, 2014 5:49 am, edited 2 times in total.
Reason: Added code tags

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by adafruit_support_bill »

Sorry, I don't know what a tag is, I looked it in my Ardunio book, it did not help me.

not sure about </>
Look just above the message editing box. There is a button marked '</>'
Press that button. It will insert two '[/code]' tags into your message.
Paste your code between the two tags.

It will look like this:

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(1);
// 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);
}
This code compiles without errors using the current version of the Library and Arduino 1.0.5 R2. What version of the the Arduino IDE are you using?

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

HI!

Ardunio 1.0.5-r2

when I go to compile the code, it stops right at
'Adafruit_MotorShield AFMS = Adafruit_MotorShield();

error: Adafruit MotorShield' does not name a type.

DCMotorTest,inc: inc: 12:45: error: utility/Adafruit_PWMSservoDrivers.h:
No such file or directory.

It names a lot more, I can't go past this point.

Thanks
Frank G.

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by Franklin97355 »

error: Adafruit MotorShield' does not name a type.
You have correctly installed the motorshield library have you not?
https://learn.adafruit.com/adafruit-all ... nstall-use will give you help with that.

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

Hi!

I followed the procedure given.

From downloaed file to sketchbook to libraries.

Its all there.

However there is one thing that get's me confused.
I don't see the zip on the master folder..

none the less I do see it.

I'll keep trying sooner or latter it will come together.

Thanks
Frank G.

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

Hi!

All it take is lots of patient then a little more.

The eye and the hand sometimes don't work together right.

However, not out of the woods yet.

new errors:

Adafruit_MotorShield / Adafruit_PWMServgo Driver.cpp:
In member function 'void Adafruit_PWMDriver::

set PWM(uint8_t, uint16_t, uint16_t',

error 'class twowire'
has no member name 'write'

Thanks
Frank G.

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by Franklin97355 »

I'm not sure what you are doing to get that error. I copied the code into a sketch and it compiled correctly. Did you install both the motorshield library and the accelstepper library

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by adafruit_support_bill »

Are you sure that you installed the complete library? The V2 motor shield library contains several sub-folders with PWM and Two-Wire library functions. You need to install the complete library, including all of those sub-folders.

frank_fg
 
Posts: 11
Joined: Thu Jun 19, 2014 3:45 pm

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by frank_fg »

Hi!

Every day is a new day, sometimes its good an other days its not.

I have been in Electronics for some time now and programming a short time say 5 years.

I should have not gotten into programming.

Right now I'm in a hole, and need a break from it all, so for now I'll wait for a better day .

Thanks
Frank G.

P.S. Keep up the good work we need you and people like, Lets its your turn now.

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

Re: Motor Shield kit v2.0 / can't get it to compile!

Post by adafruit_support_bill »

Hang in there Frank. Let us know when you are ready to give it another shot. :)

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

Return to “Ask an Engineer! VIDEO CHAT (closed)”