Go Down

Topic: Random Flashing Strobe Control (Read 1 time) previous topic - next topic


I have been away from the Arduino for about a year and am just getting back into it.  The project I am making is a random strobe controller for 8 strobe units.  The strobes I am using are self-contained and have a self-triggering circuit.  They have a ground and positive and flash at a fixed rate of 2.5 times per second.  You can control the flash sequence by controlling power (there is no manual trigger).  You to have power the circuit for a second before it will initially flash. 

So...Controlling the random sequence is fairly simple, but I will need to hold the output open for a second plus some additional time for for the circuit to charge.  Now here comes the tricky part.  If I want the strobes to fire faster than a second apart I will need to overlap when my outputs go high.  I think I will need to use some sort of psuedo mutitasking or timer variables?  I will also need to bias my random outputs so that I do not repeat the same strobe twice in a row.  Anyone have any slick ideas?



I think I will need to use some sort of psuedo mutitasking or timer variables?

By using the Blink Without Delay technique, you can have multiple delays that don't interfere with each other.

Or, they can relate to each other...  But in any case, you can have more than one timer running at the same time, since your loop runs continuously without any delays in the actual loop.

So you can trigger the 1st strobe

... Then after some delay, send a trigger to the 2nd strobe before the 1st one actually fires.

... Then, after enough time has passed for the 1st on to fire, turn it off before it can fire again.

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:


I will also need to bias my random outputs so that I do not repeat the same strobe twice in a row.
Probably the easiest solution is to put your random-variable selection in a loop (probably a while() loop) and loop 'till the random next lamp is different from the current lamp.

i.e. Pick a random NextLamp number and if NextLamp == CurrentLamp, continue looping and get another random Next Lamp.   If they are not equal (which will be true most of the time), break out of the loop.   As long as this loop is running fast enough (relative to your flash interval), you can randomly pick the same number several times in a row and you'd never see a problem.

Of course when the time is up, CurrentLamp will be assigned the value of NextLamp and you'll have to find a new-random NextLamp.

Another way to do it is to make an array which excludes the CurrentLamp, and then pick a random element from the array.   (Something like this is often done to simulate a deck of cards, where you can't select the same card again after it's removed from the deck.)


Thanks to everyone for their responses!  Lots of good ideas to keep me busy for a while.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131