Hello - I am trying to connect my Photon with a Shield Shield and an Adafruit Motor Shield and it is not working. I see a couple of posts on this but they are fairly old (+2 years) (on bottom). The Motor Shield works fine with the Arduino, but when I put it on the Photon Shield Shield, nothing (almost nothing, the stepper motor gets warm, but does not move).
Here is the code that works on the Arduino:
/*
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_MS_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);
// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
myMotor->setSpeed(10); // 10 rpm
}
void loop() {
Serial.println("Single coil steps");
myMotor->step(100, FORWARD, SINGLE);
// myMotor->step(100, BACKWARD, SINGLE);
Serial.println("Double coil steps");
myMotor->step(100, FORWARD, DOUBLE);
// myMotor->step(100, BACKWARD, DOUBLE);
Serial.println("Interleave coil steps");
myMotor->step(100, FORWARD, INTERLEAVE);
// myMotor->step(100, BACKWARD, INTERLEAVE);
Serial.println("Microstep steps");
myMotor->step(50, FORWARD, MICROSTEP);
// myMotor->step(50, BACKWARD, MICROSTEP);
}
and here is the Photon Code:
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit-MotorShield-V2.h>
// This #include statement was automatically added by the Particle IDE.
// This #include statement was automatically added by the Particle IDE.
#include <Stepper.h>
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);
// You can also make a stepper motor on M1/M2
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);
int x=0;
String outside;
void setup() {
// Put initialization like pinMode and begin functions here.
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
AFMS.begin(); // create with the default frequency 1.6KHz
myMotor->setSpeed(10);
Particle.variable("X", outside);
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
Serial.println("Single coil steps");
myMotor->step(100, FORWARD, SINGLE);
Serial.print("Spin");
delay(1000);
x=x+1;
outside = x;
}
Is this an issue of not putting the logic on the Adafruit Motor Shield to 3v?
I know this is a problem that has happened in the past, but again, most of those topics are +2 years old.