const byte blue = 11, orange = 10;
#define DUTY 25
#define BLUE_DELAY 18 //18 x 25mS Duty = 450mS delay
#define ORANGE_DELAY 35 //40 x 25mS Duty = 875mS delay
unsigned long previousMillis = 0;
int blueCount = 0, orangeCount = 0;
bool blueState = 0, orangeState = 0;
void setup() {
pinMode(blue, OUTPUT);
pinMode(orange, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= DUTY){ //Creates our 25mS non-Blocking timer
previousMillis = currentMillis; //Resets timer for next 25mS delay MANDATORY or timer won't work!
blueCount++; //Counters for delay periods greater than DUTY period
orangeCount++; // longhand "orangeCount = orangeCount + 1"
if(blueCount >= BLUE_DELAY){ //True when count = delay count
blueCount = 0; //Reset to zero for next count delay period
digitalWrite(blue, (blueState = !blueState)); //Method to toggle LED ON/OFF with ! (NOT)
}
if(orangeCount >= ORANGE_DELAY){
orangeCount = 0;
digitalWrite(orange, (orangeState = !orangeState));
}
}
}