Looking for "Random flash" in a light

I’ve noticed that random flashers on a bike attract the most attention (for me anyway). Is there a driver or stock build that has this function? I’m talking about random intensity as well as speed.

I haven’t heard of this before myself. It shouldn’t be to hard to program, I might try it for the sake of it, but I have not heard of this feature being stock.

Random is not easy! I vote for TRS (true random strobe) : the flashlight connects to random.org to generate the off-times.

The function rand() or srand() wouldn’t work?

If not, you can always generate a random string before hand and code it into the driver with memory that remembers where in the string the light was when mode is switched. It may not be true random, but depending on how long you make the string it certainly would appear random.

Everett (tterev3) can do true randomized strobes with the MLEV (and any other PIC controlled drivers he might have)

A while ago I made a flickering candle with a ATtiny13. the rand function uses huge amounts of memory in a little device, another solution is to use a linear feedback shift register, very simple code and does the same job, I might see if I can get the code to control a strobe instead of PWM.

I would LOVE a nasty random strobe J)

Yeah, you’re right. I coded a simple little strobe with random PWM level and time, and with the rand() function more than half of the memory was eaten up, totaling 650 bytes.
So I replaced rand() with a linear feedback shift register and got it down to 208 bytes. I flashed into a driver and ran it, and the strobe certainly appears random. Thanks for the tip!

Can we see the code?

Posting code is horrible on this forum… I tried, but here is a pic instead.

Here are both examples I used. I could cut the size down further by replacing the _delay_ms() with a less byte intensive delay loop I’ve edited, but this test was just to see the difference in the two random methods.


Oops too slow.

Thanks :beer:


I don’t have anything to contribute to the discussion right now. I’m just chiming in to encourage people to work on code for ‘nasty’ strobes. Also less nasty ones of course; for bicycle use we’d better not put oncoming drivers into a vegetative state.

All this (thought process) came about when I dropped an 18650 in a C-8 mounted on the seatpost of my bike. The battery was too short to make a good solid connection so with every little bump I hit, the light cycled through all of the modes. Randomly. If that’s a word. :bigsmile:

I am unsure if it has to be randomized, i guess if you have a randomized sequence which gets repeated would be almost equal in effect…I am talking of a lookup table for the frequencies to save memory

> with every little bump I hit, the light cycled

Hm, that’s simpler than using an accelerometer …

Suggested in post #3. One sequence for PWM levels, another for time. They wouldn’t have to be very long either.

A friend saw my new MELD-based light from tterev3, and decided he needed a nasty multicolor random strobe too. My attiny13a flashing hardware is still on its way so I haven’t touched the code, but I think the rest should be pretty easy with parts from RMM’s store. Everything including the host and a battery and charger comes to about $40.

Personally, I’m more interested in variable-speed strobes with really short duty cycles, for freezing moving objects in place. I spec’d out all the timings for one and Everett was nice enough to customize his firmware for me, and it turns out my spec works pretty well. So I have one light which does it and I’m planning to make a more advanced one when the rest of my hardware arrives.

Instead of delay_ms() though, I’m planning to use the PWM hardware to control the strobe. It provides higher time resolution and uses less power, but comes with the caveat that the code will have to adapt to time moving at different speeds depending on the current strobe settings.

So I tried the rand() strobe program earlier and couldn’t get it to work properly, it just flickered very slightly, but only just realised hours later that randpwm and randtime could have 50 and 2000 exchanged?

So tried a if/else statement to drive a Output pin, like this: Rand % 255, 0-100 led on / 100-255 led off. With Randtime % 30 it gives a pretty intense random strobe.

I made a couple of changes:

OCR0B = rand() % 90 + 10; // This gives a minimum of 10 and max of 100. I didn’t want to test full 255 blasts.
uint16_t randTime = rand() % 1990 + 10; // This gives a minimum delay of 10 ms and max 2000 ms

I did the same to the LFSR routin:
OCR0B = (pwm % 90) + 10;
uint16_t timeDelay = time % 1990 + 10;

It just so happened that I used different variable names for time in the two routines, but doesn’t matter.

It it makes a difference, this is how I start main for these small tests:
DDRB=2; //define PB1 as output
TCCR0A=0b00100001; TCCR0B=0b00000001; //PWM setup, 9kHz
OCR0B=5; //set PWM level

If you want to see it all you can download my source at http://www.mikec.se/Stuff/MikeCT1.zip
It also has a fading strobe/beacon I wanted to test.

Everything is commented out… Just uncomment between the = rows to run the specific routine.

Hello everyone. I am a newbie so please forgive the basic questions.

I am building a small light sculpture at Burning Man and am scouring the web for a light source that can emit a strobe, random in both frequency and intensity.

This thread looks very interesting, however everyone here is talking in terms and abbreviations that I do not understand.

Would someone be so kind to guide me through the process of achieving this effect? (what parts to get and possibly where and dare I say it, point me in a direction where I could obtain schematics if necessary?)

Thank you for your time.

How far along are you? You’ll need to flash an ATtiny13A MCU after you compile a firmware.. Depending on how much light you need there are different driver options. The Nanjg 105c is really the prototypical driver for most of our efforts. These efforts largely started with Tido’s BLF-VLD firmware. While his firmware is not as commonly used or discussed anymore, the initial info thread kicked things off and is still a great start for beginners. Related information is also available on this wiki page.

I don’t know what the power requirements of your burning man project will be, but RBD maintains a list including some other drivers you could use.

All that said, be very careful if you aren’t that familiar with LEDs and electronics. If you are running your project on a big battery (car battery, deep cycle, many 18650’s in parallel, etc) then the popular “DD” drivers may not be appropriate (they may destroy LEDs depending on the input to the driver).