I am attempting to make a cheap and simple "quantum-ish" coin flip circuit. My idea is to use something like an SR latch driving two LEDs, and have the initialization be driven by some random event.

I will be cross-posting in the physics stack exchange as for what could qualify as a quantum trigger, but my initial thought was to compare the resistance of two LDRs in the dark as a "quantum" event. So essentially the SR latch would be powered up and whichever LDR had a slightly lower/higher resistance would drive the latch to initialize in that state and stay there until power is removed.

What would a circuit like that look like? Is there any way I can tune it so that the probability is approximately 50-50 for each LED.

  • \$\begingroup\$ Is the coin flip triggered by a human button push. If yes, use the duration of the button push to randomize. \$\endgroup\$ – Mattman944 Jun 25 '19 at 19:25
  • 1
    \$\begingroup\$ If it is truly a Quantum state. Just looking at it flips the expected state. But you may want it simple or lots of Entropy. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jun 25 '19 at 19:34
  • 1
    \$\begingroup\$ I suspect if you take 2 LDRs and measure the resistances, you will get the same result every time, because of slight manufacturing differences. \$\endgroup\$ – Simon B Jun 26 '19 at 8:02

This is 50-50.

edit: Above may have Nch-Pch square symmetry error with temp so added divide by 2 and raised clock to 100kHz and removed inverter so it selects random binary phase from LPF filtered rising clock.

Improved Sim with noise injected for test on supply.

Use any button switch to ground.

Extra LED's with Shift Register to see history.

Clock frequency is so fast compared to human response, it is random.

enter image description here

  • A leaky cap with 1MΩ resistance will offset the 50-50 by Rf/1MΩ = 1kΩ/1MΩ=0.1%
  • 10kΩ Series to protect CMOS input.
  • Small signal diode to prevent V- on rapid button pushing.
  • A good ceramic cap is 50 seconds=ΩF so 100nF = 500 MΩ but then dirt flux is less than this.
  • Do you feel lucky guessing the next or how many times to get 9 same in a row?
  • \$\begingroup\$ The latching half is a great start. I'd like to have the signal half run in a slightly more random manner though. Is it possible to have the output of the schmitt be generated by whether the resistance of one photoresistor is higher than the other? \$\endgroup\$ – Will Stedden Jun 25 '19 at 22:29
  • \$\begingroup\$ Try it out and see how long it takes to get consecutive 0’s and 1’s . It should be equal. For a string of 8 or 9 and don’t use anything high impedance unless just a switch with a shunt cap. Adding a random clock won’t add any entropy. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jun 25 '19 at 22:31
  • \$\begingroup\$ Yes it’s possible to use differential Photo resistors but photo diodes are much more accurate in the same ambient. Noise is a concern with lighting flicker unless daylight blocking filters are used with IR light \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jun 25 '19 at 22:41
  • 1
    \$\begingroup\$ The schmitt trigger oscillator duty cycle may not be exactly 50%, I recommend a divide by 2 before the F/F D input. \$\endgroup\$ – Mattman944 Jun 25 '19 at 22:55
  • \$\begingroup\$ The entropy for this simulation is very poor. Just hold the button down for more than a few seconds each time. Generation of random numbers is hard and even physical circuits such as this will 'sync' to minute fluctuations in the power supply or chip current paths. I'd suggest that the best solution would be to use a small MCU using the internal RC clock generator. An ATTiny85 can be had for less than $1 and produces quite acceptable results. \$\endgroup\$ – Jack Creasey Jun 26 '19 at 5:04

Creating a random number generator with adequate entropy is very very hard.
Using any simple logic solution is likely doomed since the isolation between elements and limited PSRR means its easy to end up with some form of sync that degrades the entropy result.

The classical way has been to generate random noise and then A/D or level detect this to get good entropy. The solutions here tend to be complex, but do deliver reasonable results.
I'm not sure how effective an LDR would be (it's a single typically N based material with no tunneling capability), in the past I've used either photodiodes or reverse biased transistors to provide the quantum effect. See here and here.

If you are looking for an easy, cheap and reliable digital implementation, you might try this RC oscillator based solution.

I've used a modification of the 'jitter' library with an ATTiny85 where the WDT and System 'RC' clocks are separate. I used a 'Digispark' initially but now use the ATTiny85 running at 3V using a TL431 shunt regulator to give good PSRR. It's an easy solution to lay out on a PCB, and I don't use the ATTiny for any other purpose, just as a RNG. The nice part of the solution is that I can use the Arduino PRNG with a fixed seed value for debug and switch to the TRNG using an input pin. The results are very encouraging and you can view the Entropy site information here.

You might also gain some insight from reading this StackOverflow answer.


I think I have a solution that matches my request. I am going to use two photodiodes as input to an op-amp comparator (https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html). The output of the op-amp will then be the input to a D flip flop.

I have made an example circuit here.

Note that for this I am faking a photodiode as a small random signal connected to a transistor. This is similar to how photodiodes work in photoconductive mode (https://www.rp-photonics.com/photodiodes.html) where the small signal is actually generated by the photon absorption.

  • \$\begingroup\$ Have you built this yet? I am curious to see if will be close to 50-50%. I predict that you will have difficulty due to component variations. \$\endgroup\$ – Mattman944 Jul 8 '19 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.