const int drivePin = 13; // For Arduino
//const int drivePin = 1; // For Digispark_see text
unsigned int driveState = HIGH;
long idleTime = 6000; //OFF TIME_see text
long activeTime = 3000; //ON TIME_see text
unsigned long previousMillis = 0;
void setup() {
pinMode(drivePin, OUTPUT);
driveState = HIGH;
digitalWrite(drivePin, HIGH);
}
void loop() {
long currentMillis = millis();
if ((driveState == LOW) && (currentMillis - previousMillis >= idleTime))
{
driveState = HIGH;
previousMillis = currentMillis;
digitalWrite(drivePin, HIGH);
}
else if ((driveState == HIGH) && (currentMillis - previousMillis >= activeTime))
{
driveState = LOW;
previousMillis = currentMillis;
digitalWrite(drivePin, LOW);
}
}