Random sequence of 4 LEDs

rjjenkins

Joined Apr 16, 2011
178
Hello

I want to make a circuit that flashes four LEDs (or reed relays) in a pseudo-random sequence, with each flash lasting about half a second. It's important that only one LED is on a time, and I want it to be automatic (eg not triggered by pushing a switch). I feel that this ought to be fairly easy but I don't quite see how to do it and don't want to reinvent the wheel. Help appreciated, thanks

iONic

Joined Nov 16, 2007
1,650
Sometimes divulging a little bit more of your intentions can be a help to those offering assistance. For example: There seems to be a hole lot of difference between turning on LED's "or" Reed relays.

A 555 along with a 4017 counter IC might be a place to start. You might only have to modify the "wheel".

Randome Dice

#12

Joined Nov 30, 2010
18,217
A very quick first impression...(4) 555 timers (or other sort of oscillator) with a circuit that latches out all other LEDs if any one of them is using the available current. Kind of like a game show lockout circuit.

rjjenkins

Joined Apr 16, 2011
178
Sorry, it's really the relays I want but I've spent so long reading about LED flashers that I was in LED mode when I started to type. Does it make a huge difference which it is? I'm thinking of those v small relays that you can drive straight from logic circuits.

So I could use a 555 to generate a fast clock pulse going to the 4017 and then another 555 going at a slower clock rate to stop and start the first one ... ?

Sometimes divulging a little bit more of your intentions can be a help to those offering assistance. For example: There seems to be a hole lot of difference between turning on LED's "or" Reed relays.

A 555 along with a 4017 counter IC might be a place to start. You might only have to modify the "wheel".

Randome Dice

rjjenkins

Joined Apr 16, 2011
178
A very quick first impression...(4) 555 timers (or other sort of oscillator) with a circuit that latches out all other LEDs if any one of them is using the available current. Kind of like a game show lockout circuit.

Yes thanks I think that would work although uses more chips than I really want

SgtWookie

Joined Jul 17, 2007
22,221
Well, 555 timers tend to get into "lock step" with each other - and I have a feeling that it won't appear to be very random.

I'm playing around with a LFBR (linear feedback register) driving a 2 to 4 mux. It has pretty good randomness and only one LED on at a time, but occasionally one LED will stay on for a number of clock cycles (2 or more) making it appear "stuck". I think our OP wants a different LED to show on each clock cycle.

THE_RB

Joined Feb 11, 2008
5,438
Sorry, it's really the relays I want but I've spent so long reading about LED flashers that I was in LED mode when I started to type. Does it make a huge difference which it is? I'm thinking of those v small relays that you can drive straight from logic circuits.

So I could use a 555 to generate a fast clock pulse going to the 4017 and then another 555 going at a slower clock rate to stop and start the first one ... ?
Yep apart from the best choice (a microcontoller) that would be the next best way to do it. A 556 and a 4017.

You will need to ensure the relays can't turn on when the 4017 is in fast mode, which should be easy enough with 4 drive transistors and RC networks so the average 50% (fast cycling) duty causes less than 0.4v at the transistor base and only when it stops will make about 0.8v at the transistor base to ensure turn on of that one transistor.

Because all the little electronics I know I learned in the clunky 1970s. I know nothing about $1 microcontollers. Where would be a good place to start? SgtWookie Joined Jul 17, 2007 22,221 By "nearby", I mean within an inch. The longer the wiring, the greater the inductance. You want the bypass capacitor wiring to be as short as possible. k7elp60 Joined Nov 4, 2008 562 I think SgtWookie's idea is better. I think that for parts reduction only 1 resistor is needed for all four LED's. That is remove the resistors from the anodes of the LED's. Connect all the cathodes together and place on resistor from the cathodes to ground. colinb Joined Jun 15, 2011 351 Because all the little electronics I know I learned in the clunky 1970s. I know nothing about$1 microcontollers. Where would be a good place to start?
There are lots of ways to start.

You could start with the bare-metal and work up: Get an AVR, PIC, or ARM Cortex-M0/M3 microcontroller, make a circuit, program it in assembly code. Then write C code. Then implement more complex programs and use more peripherals such as timers, power-save mode controls, UARTs, SPI, interrupts, etc.

Or, you could start with a ready-to-rock and quick-start development board like Arduino, LeafLabs Maple, STM32VLDISCOVERY, etc., which provide examples and are basically ready to have you editing their Hello, World code right out of the box. Once you have the standard examples working, you can go lower level: use the AVR MCU registers directly instead of through the Arduino library API, write some assembly language code, play with interrupt handlers, timers, and learn about concurrent programming and state machines.

Once you have a feel for microcontrollers, and have used a particular one on a dev board, you can use the bare chip in your own circuit easily. The dev boards are $10 to$50 but the microcontrollers themselves may cost only $1.00 to$5.00 depending on flash and RAM size, maximum clock speed, etc.

The Arduino uses a medium-size ATmega328, but for your simple LED controller, you can go REALLY small with an ATtiny13 or something.

Wendy

Joined Mar 24, 2008
22,237
I think I could do better with qty 3 555, loosely based on this circuit...

Decoupling individual 555's isn't hard, though I won't make that claim for 556's (dual 555's).

If the OP is interested I will post a circuit I think would work.

rjjenkins

Joined Apr 16, 2011
178
If the OP is interested I will post a circuit I think would work.
Yes, he is interested, thanks

rjjenkins

Joined Apr 16, 2011
178
There are lots of ways to start.

You could start with the bare-metal and work up: Get an AVR, PIC, or ARM Cortex-M0/M3 microcontroller, make a circuit, program it in assembly code. Then write C code. Then implement more complex programs and use more peripherals such as timers, power-save mode controls, UARTs, SPI, interrupts, etc.

Or, you could start with a ready-to-rock and quick-start development board like Arduino, LeafLabs Maple, STM32VLDISCOVERY, etc., which provide examples and are basically ready to have you editing their Hello, World code right out of the box. Once you have the standard examples working, you can go lower level: use the AVR MCU registers directly instead of through the Arduino library API, write some assembly language code, play with interrupt handlers, timers, and learn about concurrent programming and state machines.

Once you have a feel for microcontrollers, and have used a particular one on a dev board, you can use the bare chip in your own circuit easily. The dev boards are $10 to$50 but the microcontrollers themselves may cost only $1.00 to$5.00 depending on flash and RAM size, maximum clock speed, etc.

The Arduino uses a medium-size ATmega328, but for your simple LED controller, you can go REALLY small with an ATtiny13 or something.
Thanks. Sounds like something for the long winter evenings!

SgtWookie

Joined Jul 17, 2007
22,221
I think I could do better with qty 3 555, loosely based on this circuit...

Decoupling individual 555's isn't hard, though I won't make that claim for 556's (dual 555's).
Bill,
When you posted that link to your blog, it wasn't to a specific circuit - it was to the whole blog. Which one were you thinking of using?

Wendy

Joined Mar 24, 2008
22,237
Bill,
When you posted that link to your blog, it wasn't to a specific circuit - it was to the whole blog. Which one were you thinking of using?
Try clicking the link, then look at the schematic that comes up. It is "From 4 Twenty", Figure 8.1, which was intentional. The rest of the blog is there, unlike posts and threads, but it goes right to the location I meant it too.

OK, I did a quick modification of Figure 8.1. This circuit has been built without decoupling the 555's with good results, but I included how to decouple it if needed.

It has 6 LEDs, feel free to eliminate the two you don't like. Don't take one from two clusters though, the back to back LEDs are deliberate, and protect the LEDs from back voltage.

I would be temped to replace R1-3 with two resistors, say 47KΩ and a variable 100KΩ. This would allow you to tweak the flash pattern. I thought of doing something like that for a busy box for a kid.

The "From 4 Twenty" schematic would be great for a electronics Christmas tree.
.

Attachments

• 6.9 KB Views: 111
Last edited:

SgtWookie

Joined Jul 17, 2007
22,221
That's basically "sort of" a Charlieplexing scheme; but missing the high impedance state.
http://en.wikipedia.org/wiki/Charlieplexing

If a pair of LEDs is removed, you'll wind up with all of the LEDs being off about 1/3 of the time. Also, without the high impedance state, you'll wind up with more than one LED lit fairly frequently; 1 & 4 or 2 & 3.

Have a look at the attached; it's basically figure 8.1 with R14, D11 and D12 removed, and a simulation of the circuit. I left most components at the values Bill set (except C4-C6; they're not terribly critical).

I somewhat arbitrarily selected 9v for Vcc; the values Bill chose would work OK up to around 13v.

Attachments

• 126.8 KB Views: 38
Last edited: