// for https://forum.arduino.cc/t/using-millis-with-a-l293d-motor-shield/981029/7
#include "AFMotor.h" // https://github.com/adafruit/Adafruit-Motor-Shield-library
//
AF_DCMotor motor4 (4);
int motor4State = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
AF_DCMotor motor4 (4);
motor4.setSpeed (254);
motor4.run(RELEASE);
motor4.run(FORWARD);
//turn on motors
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
if (motor4State) {
motor4.run(RELEASE);
motor4State = HIGH;
} else {
motor4.run(FORWARD);
motor4State = LOW;
}
}
}