Based on the script below from
(https://arduino.stackexchange.com/quest … 6777_90286)
I connected it to SparkFun RedBoard Plus, Qwiic LED Stick - APA102C, Adafruit Stepper motor - NEMA-17 size - 200 steps/rev and Adafruit Motor Shield V2. It seems that there is a delay of the LED blink when the motor is running. Why? Is it fixable?
In addition, I tried it with RedBoard Plus
And Turbo but it does not work at all. Any idea why?
Thanks a lot
Script:
#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(9600);
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);
}