This sketch is designed for TrueRNG devices and:
-
Connects to a TrueRNG hardware random number generator exposed
as a serial (USB CDC) port, reading bytes in real time.
-
Unpacks each byte into 8 bits and groups them into
fixed-length “GCP-style” blocks (1 second per block by default).
-
For every block, counts the ones, computes a z-score for deviation
from 50/50, and accumulates these into a cumulative z-score series.
-
Draws a live graph of cumulative z versus block index, with
significance lines at
±1.96 (≈ p = 0.05).
The UI panel at the top lets you:
-
Choose a serial port for your TrueRNG, a goal
(High / Medium / Low), and a run duration
(1 min, 3 mins, 5 mins, or Continuous).
-
Use a single Start Run / Stop Run button to begin a test or
stop it manually.
When a run ends (either by time limit or manual stop in continuous mode), the sketch:
- High goal: HIT if final cumulative z ≥ +1.96.
- Low goal: HIT if final cumulative z ≤ −1.96.
- Medium goal: HIT if |final cumulative z| ≤ 1.0.
The outcome is shown as a HIT or MISS banner
with the final cumulative z-score so you can compare multiple runs.