Modified code:
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "Qwiic_LED_Stick.h" // Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_LED_Stick
// Variables will change:
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
// constants won't change:
const long interval = 500; // interval at which to blink (milliseconds)
LED LEDStick; //Create an object of the LED class
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
void setup() {
Wire.begin();
Serial.begin(115200);
while (!Serial);
Serial.println("Stepper test!");
if (!AFMS.begin()) {
// if (!AFMS.begin(1000)) {
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");
myMotor->setSpeed(50); // 50 rpm
//Start up communication with the LED Stick
if (!LEDStick.begin()) {
Serial.println("Qwiic LED Stick failed to begin. Please check wiring and try again!");
while (1);
}
Serial.println("Qwiic LED Stick ready!");
// LEDStick.setLEDColor(255, 0, 0);
LEDStick.setLEDBrightness(1);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
ledState = !ledState;
// set the LED with the ledState of the variable:
uint8_t intensity = ledState == HIGH ? 255 : 0;
LEDStick.setLEDColor(intensity, intensity, intensity);
}
Serial.println("Single coil steps");
myMotor->step(200, FORWARD, SINGLE);
}
Code: