Can someone PLEASE help me with the coding on this.
What I would like to see it do is BEFORE this code shown below is run for 20 seconds,
double flash pins 11,12, double flash pins 9,10.
I guess this is also called wig-wag. on a police car
where one side does a flash flash, then other side does a flash flash
and have that run for 10 seconds, then start the code below, to run for 20 seconds, then after 20 seconds, start the double flash again.
Once i see that written out and working, I think it will help me easier design more flash patterns to add them to the loop.
but when i try it myself, it just dont work.
int red = 12;
int blu = 11;
int wht1 = 10;
int wht2 = 9;
int redblue_time = 160;
int whtwht_time = 120;
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;
}
}