[REQUESTED]Adafruit-Motorshield-V2 Library for Photon

Hi All!

I need to control a stepper motor by using the Particle Photon and the Adafruit Motorshield V2, and am having a lot of trouble getting it to work. I am fully aware of this post here, Adafruit Motor Shield V2 Library [PORTED] . However, this post is written with the Spark Core in mind, not the Photon. Having said this, I have tried everything to get it to work. I have configured the spark and shield exactly as shown in this video, https://www.youtube.com/watch?v=629VVNp0Z5Y . The code I am using is the Adafruit-Motorshield-Example.cpp file from the Adafruit-Motorshield-V2 library in the web IDE, as was recommended in the other post.

Having done all this, I cannot get the motor to spin at all. I have the same motor as shown in the video, and I am sure that it works, because I was using it with Arduino just last week.

If someone could please help me figure out how to get this motor running I would be extremely grateful. I am very new to all this kind of stuff so please forgive me if I ask any dumb questions in response. Please help, I really need this to work! Thanks!

I wanted to look into this yesterday night but the internet did not give me a chance to. Will do this later :smile:

@mastap94 i just checked. The library seems to be updated but the version is not bumped.

I will be working with the library contributor to bump it as soon as possible :smile:

1 Like

@kennethlimcp, sorry if this is a dumb question, but what exactly do you mean by “bumped”? (Sorry, I’m new to all the jargon!)

It just means the library was updated in github but not in the Web IDE :smile:

Thanks @kennethlimcp! Can you possibly send me the link to the github library?

Is there any way I can use the code before it actually gets bumped? i.e. Is there any way I can do it myself? I really need this asap :confused:

You can try using CLI to compile it.

@kennethlimcp, Is this not identical to what is currently in the web IDE? It says that nothing has been updated in over a year, and it mentions nothing about being compatible with the photon… Also how exactly do I go about using CLI to compile it? Can I not just copy paste the code from here into the existing web IDE code?

You can do that as well.

Look at the include path. I think it is different compared to the Web IDE version.

Ok great, thanks! But just to be clear, isn’t the stuff on github the same stuff from the IDE? Like I said above, it hasn’t been updated in a year and does not say anything about being compatible with photon?

It looks more like libraries structure issue to me that it failed for core or photon. Or is that not the case for you?

Sorry, I don’t think I understand what you mean :confused: … The library appears to work fine for the core, but I can’t get it working with my photon. I thought that the photon and core were nearly identical devices? Is there any reason that the code would work for the core but not the photon?

Hi, @mastap94, did you manage to get it working with the Photon? The library seems to be crashing the core, so I thought I’d give it a try with a photon. Thanks!

Hi @mastap94, I have exactly the same problem as you describe with the Adafruit Motorshield v.2 and Photon, did you ever solve this ? If you did could you please give me a hint on how you did it.

It would be more helpful to actually state what your problem is than just saying it’s the same, because this is highky unlikely after this long and the updated version being put onto Particle Build meanwhile.

I’ve just built the adafruit-motorshield-example without any problem.

@ScruffR Thanks for your reply and advise,

I have hooked up the Adafruit Motor shield v2.3 to my Photon as described in a previous thread:

Shield A4 and A5 to D0(SDA) and D1(SCL) on the Photon.
Vin and Gnd from Photon to Vin and Gnd on the Shield. I have a separate power supply (battery) 7,4V connected to motor power and a small DC motor connected to M1. I also set the Shield to 3V logic.

I added the Adafruit Motor shield V2 lib to my code and have successfully compiled including the test code as below, but I do not get any action from the M1/motor.

I am quite new to this so probably a rookie mistake, or??

#include "application.h"
#include "Adafruit-MotorShield-V2/Adafruit-MotorShield-V2.h"
#include "Adafruit-MotorShield-V2/Adafruit_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);

void setup() {
  Serial.begin(9600);  
  AFMS.begin();  
  myMotor->setSpeed(100);
}
void loop() {
  myMotor->run(FORWARD);
  Serial.print("run");
  delay(1000);
}

You won’t believe what we’ve seen today, so could you please shoot and post a pic (or a couple) of your current wiring?

Absolutely, I hope I wont beat that…

Since I have been trying some different options for the set-up there are some non-used jumper cables in “parking position” on the breadboard.

SOLVED!

I did not realize I had to feed the Shield at the 3V “pin” when it is set for 3V logic. Thanks for listening!

1 Like