Hello all,
Please forgive any newbie mistakes i make as i am a first time poster and relatively new to the whole arduino coding world.
My problem is that I am trying to create a realistic flash pattern for an R/C police car and I can get the lights to flash perfect each on their own routine, but i cannot combine 2 routines run simultaneously.
I am trying to make the usual blue and red lights strobe back and forth WHILE also having a traffic arrow of 8 LEDs move to the left. I cannot figure out the code to make this work. I understand i cannot use DELAY and that i should be using MILLIS() but i am having trouble grasping how to code a "4 quick blink" type of strobe light with millis(). And same thing with the traffic arrow. The code below works perfectly but all it will do is show you what i want to achieve, i am perplexed on how to write this same code in a way that i can have the strobes flashing while the arrow moves across... ![]()
Physical setup looks like this:
B lue LED
R ed LED
Y ellow LED
R R R Y Y Y Y Y Y Y Y B B B
i left out some of the other code required to make this work, but i did get it to work ok, the code itself is not the problem, its how to rewrite it that is making me nuts. Thanks so much for any insight ! ![]()
```
// R/C police car rear yellow traffic arrow, moving
// from right to left with a double blink on the final led
void ta_left(){
int delayTime = 150;
for(int i = 7; i >= 0; i--){
changeLED(i,OFF);
}
for(int i = 7; i >= 0; i--){
changeLED(i,ON);
delay(delayTime);
}
delay(delayTime);
changeLED(0,OFF);
delay(delayTime);
changeLED(0,ON);
delay(delayTime);
changeLED(0,OFF);
delay(delayTime);
changeLED(0,ON);
delay(500);
}
// R/C police car strobe blue and red lights, 4 quick blinks one side,
//then 4 quick blinks the other side (back and forth)
void strobes (){
for(int x=0;x<4; x++){
digitalWrite(6, HIGH) ;
digitalWrite(7, LOW) ;
delay(25);
digitalWrite(6, LOW) ;
digitalWrite(7, LOW) ;
delay(60);
}
for(int y=0;y<4; y++){
digitalWrite(6, LOW) ;
digitalWrite(7, HIGH) ;
delay (25);
digitalWrite(6, LOW) ;
digitalWrite(7, LOW) ;
delay(60);
}
}