PH 250 · Team project

A Random Number Generator Built From a Red LED

A reverse-biased LED, a 1 MΩ resistor and an Arduino Uno detect single photons and turn the time between them into random bytes.

Team
Nels Buhrley, Rex Wight, Andrew Simmons
Course
PH 250
Presented
November 11, 2025
Stack
Arduino (C++), Python

Most random numbers on a computer come from an algorithm: give it the same seed and you get the same output. We wanted randomness from physics instead, using light detection at the single-photon level, built from parts that cost a few dollars.

The detector

A single-photon avalanche detector (SPAD) is a diode biased past its breakdown voltage, known as Geiger mode. One photon creates an electron–hole pair, which sets off an avalanche of current. A quenching circuit then stops the avalanche, the diode recovers during a short dead time, and it is ready for the next photon.

An ordinary red LED can do this when it is reverse-biased. We used passive quenching: a 1 MΩ resistor in series with the LED, with the voltage across it read on the Arduino Uno’s analog pin A0. The circuit sat inside a black box to limit how much light reached it.

Schematic: a DC voltage supply reverse-biases a red LED inside a light-limiting box. The LED's other side meets a node that goes to ground through a 1 megaohm quench resistor and to pin A0 of an Arduino Uno; the Arduino ground shares the same ground rail. Light-limiting box DC supply reverse-biases the LED photons Detector: red LED single-photon avalanches (Geiger mode) 1 MΩ passive quench ~150 μs pulse A0 GND Arduino Uno times pulse gaps, outputs random bytes
Fig. 1The circuit. The reverse-biased LED sits in the light-limiting box; each avalanche drives a voltage pulse across the 1 MΩ resistor, which the Arduino reads on pin A0.
Close-up of a red LED and a resistor on a small breadboard mounted on an Arduino shield, with oscilloscope probe clips attached, inside a dark enclosure.
Fig. 2The build: LED and quenching resistor on a breadboard shield, with oscilloscope probes attached, inside the light-limiting box.

Seeing single photons

On the oscilloscope, each detected photon appears as a sharp pulse well above the noise floor that decays over roughly 150 µs. When a second photon arrives before the first pulse has fully decayed, its pulse rides on the first one’s tail. That is the detector’s dead time and pile-up made visible.

Oscilloscope screen at 50 microseconds per division showing a noisy baseline, then two sharp pulses that each decay over about three divisions; the second starts on the tail of the first.
Fig. 3Two avalanche pulses at 50 µs per division. The second pulse begins before the first has returned to baseline.

From pulses to bits

Photon arrivals are random, so the time between them is too. The Arduino firmware watches pin A0 and times the gap from the end of one pulse to the start of the next. It compares two gaps in a row to make one raw bit: 1 if the first gap is shorter, 0 if not.

Raw bits can still carry a bias, so the firmware applies Von Neumann debiasing. It takes raw bits in pairs and keeps a pair only when the two bits differ, discarding 00 and 11. Eight kept bits are packed into a byte and sent over serial. A second sketch logs each pulse’s duration and average height as CSV, which we used to look at the detector itself.

Scatter plot of 10,000 output values from 0 to 255 against time over about 500 seconds, spread evenly across the whole range.
Fig. 410,000 output bytes plotted against time. The values fill the full 0–255 range with no visible pattern.

What we learned

An LED does work as a SPAD, though it is less effective than purpose-built detectors. It is still a cheap, hands-on route to a true random number generator driven by a quantum process rather than a seeded algorithm. The next step we proposed is active quenching, which would reset the detector faster and raise the count rate.

Using an LED as a single-photon detector is an established technique; we built on these sources:

Team and tools

PH 250 project team

  • Nels Buhrley
  • Rex Wight
  • Andrew Simmons

Presented November 11, 2025.

  • Arduino Uno
  • C++
  • Python
  • Oscilloscope
  • SPAD
  • Von Neumann debiasing