sigh
Must be bored tonight.
Here.
Tested. Not optimized.. not best way, not the only way. Works 100% as described.
/* Police Undercover Car Light Sequence */
int red = 12;
int blu = 11;
int wht1 = 10;
int wht2 = 9;
int redblue_time = 40;
int whtwht_time = 450;
long last_redblue = 0;
long last_whtwht = 0;
long time_now;
bool red_state = HIGH;
bool blue_state = LOW;
bool wht1_state = HIGH;
bool wht2_state = LOW;
// Red & Blue Lights
void setup()
{
pinMode(blu, OUTPUT);
pinMode(red, OUTPUT);
pinMode(wht1, OUTPUT);
pinMode(wht2, OUTPUT);
}
void loop()
{
time_now=millis();
if ((time_now - last_redblue) > redblue_time)
{
if (red_state == HIGH)
{
red_state=LOW;
blue_state=HIGH;
}
else
{
red_state=HIGH;
blue_state=LOW;
}
digitalWrite(red,red_state);
digitalWrite(blu,blue_state);
last_redblue=time_now;
}
if ((time_now - last_whtwht) > whtwht_time)
{
if (wht1_state == HIGH)
{
wht1_state=LOW;
wht2_state=HIGH;
}
else
{
wht1_state=HIGH;
wht2_state=LOW;
}
digitalWrite(wht1,wht1_state);
digitalWrite(wht2,wht2_state);
last_whtwht=time_now;
}
}