Button Press Random True or false answer

Thread Starter

roro36

Joined Sep 7, 2010
52
Simple project that I could do on a microcontroller, but thought I would give this a shot to see for simpler solutions. I want to have a unit that has a push switch and 2 leds on it. One red and the other green. When the button is pressed, one of the lights should turn on. This should be random or be able to set which one is prefeered. So say 80% red and 20% green? Any simple solutions?
 

John P

Joined Oct 14, 2008
2,026
No, for once this is easy without a microcontroller. Just have a fast oscillator driving a divide-by-2 circuit (I'd use a 74HC74, but there are lots of ways to do it). Push the button, and the clock stops, and with the fast input, you'd never be able to predict which way it would end up.

The 74HC74 has two flipflops on the chip, so you could use the other one to implement a stop/run function.
 

THE_RB

Joined Feb 11, 2008
5,438
I believe JohnP was suggesting a traditional heads/tails generator where the divide by 2 circuit is used to ensure a fair 50:50 coin toss?

As for the weighted coin toss, you could do it in analogue with a 555 astable, set up with a pot for duty cycle adjust (to set heads/tails ratio).

Then gate and capture the running 555's output with a logic latch controlled by the button.
 

KJ6EAD

Joined Apr 30, 2011
1,581
You can use the traditional wheel of fortune circuit (pushbutton, fast (to humans) clock, decade counter, decode logic). You can also find a variation of this circuit used for electronic dice. It's just a 555 and a 4017 with 8 of the 4017 outputs going to one LED and the other 2 going to the second LED.
 
Last edited:

John P

Joined Oct 14, 2008
2,026
My earlier message just addressed the issue of a random red/green output, with a 50/50 chance of either. If you want a variable chance, it gets more complicated.

Yes, the 555 (or other) oscillator would do it. Then you'd want to have the input to the flipflop get "frozen" by pressing a button, as Roman said. But with an analog technique, you'd never get an exactly even chance of either red or green coming up. Would it be feasible to have two different methods with a switch to select one? Or maybe use a radio-style volume control, where the knob would "click" at one end of its travel, where you'd get the 50/50 chance.

Or there are digital schemes where you could have a multi-position knob that would select between various probabilities of getting each output. But then it starts to look as if the processor would be easier.
 
Top