I am using an Adafruit motor shield v2 to make a NEMA stepper motor move. I want to test the motor using the StepperTest example provided by the Adafruit library. I am getting this error: Error Compiling for board Arduino Uno. I have all my libraries installed, but I am still getting this compiling error. What am I missing?
If you're using IDE 1.8.x, there is a button "copy error messages" at the right in the orange bar.
Click it to copy and next paste it here between code tags.
Also post your code between code tags.
Inc ase you haven't read it yet, How to get the best out of this forum has a description how to use code tags.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project See About the Installation & Troubleshooting category.
Hi @oxygen02
welcome to the arduino forum
Thank you for the guidance I will follow preferred format.
Here is the copied error:
Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"
In file included from C:\Users\anish.patel\Documents\Arduino\libraries\Adafruit_Motor_Shield_V2_Library-1.1.0/Adafruit_MotorShield.h:20:0,
from C:\Users\anish.patel\Documents\Arduino\libraries\Adafruit_Motor_Shield_V2_Library-1.1.0\examples\StepperTest\StepperTest.ino:10:
C:\Users\anish.patel\Documents\Arduino\libraries\Adafruit_Motor_Shield_V2_Library-1.1.0/utility/Adafruit_MS_PWMServoDriver.h:27:10: fatal error: Adafruit_I2CDevice.h: No such file or directory
#include <Adafruit_I2CDevice.h>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is the code:
/*
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 <Adafruit_MotorShield.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, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
while (!Serial);
Serial.println("Stepper test!");
if (!AFMS.begin()) { // create with the default frequency 1.6KHz
// if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");
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);
}
I think I have everything that is needed. Can you let me know if I am missing anything?
thank you
The short error-text says this
Adafruit_MS_PWMServoDriver.h:27:10: fatal error: Adafruit_I2CDevice.h: No such file or directory
and the error-text explains
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
If you would have done the adjustements linked to in post #3
you would have already provided the detail information needed to analyse the error
I guess the Adafruit_MotorShield.h-library has dependencies that you did not install
If you install a library with the Arduino-IDE-library manager and this library has dependencies the library manager asks you if you want to install these other libraries too then you should choose yes.
best regards Stefan
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.