QRNG - Quantum Random Number Generator based Arduino and Blynk.
The QRNGv1 (Now QRNG_BASIC) was originally a proof of concept for quantum technology applications, specifically in this case for the generation of entropy which has a broad range of uses from generating graphics to encryption keys.
The device uses a polarizing beam splitter to split a laser pulse into two beams with a 50/50 probability of a photon in the beam traveling either path. The photons actually travel as a wave, meaning they both pass through and are reflected by the beam splitter. This creates what’s known as the superposition of light where the light remains in both paths able to interfere with itself until it is measured and collapses out of superposition.
Sketch for Blynk made by me:
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
char auth[] = "lRDcX5bBr1FuTzgY49iPUbPq2f2uuX8z";
char server[] = "10.5.51.5";
#define W5100_CS 10
int triggerPin = 2;
int hPin = A0;
int vPin = A1;
float H = 0;
float V = 0;
bool xtra = 0;
int x;
int y;
int z;
BlynkTimer timer;
BLYNK_WRITE(V0)
{
x = param.asInt();
}
BLYNK_WRITE(V2)
{
y = param.asInt();
}
BLYNK_WRITE(V4)
{
z = param.asInt();
}
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(triggerPin, OUTPUT);
Blynk.begin(auth, server, 8080);
timer.setInterval(0L, quantum);
}
float angle() {
float a = degrees(atan(V / H));
return a;
}
void HGate() {
digitalWrite(triggerPin, HIGH);
digitalWrite(triggerPin, LOW);
H = analogRead(hPin);
V = analogRead(vPin);
}
int Rand() {
HGate();
if (H > V) {
return 0;
} if (H < V) {
return 1;
} else {
Rand();
}
}
void extra() {
if (xtra) {
Serial.print("\nH: ");
Serial.print(H);
Blynk.virtualWrite(V5, H);
Serial.print("\nV: ");
Serial.print(V);
Blynk.virtualWrite(V6, V);
Serial.print('\n');
}
}
void quantum() {
char val = Serial.read();
if (z == 1) {
if (xtra == 0) {
Serial.print(">Printing Extra Information\n");
Blynk.virtualWrite(V7, "Printing Extra Information");
xtra = 1;
} else {
Serial.print(">Not Printing Extra Information\n");
Blynk.virtualWrite(V7, "Not Printing Extra Information");
xtra = 0;
}
}
if (x == 1) {
HGate();
Blynk.virtualWrite(V1, angle());
extra();
}
if (y == 1) {
Blynk.virtualWrite(V3, Rand());
extra();
}
if (val == 't') {
Serial.print("Success!\n");
}
if (val == 'v') {
Serial.print("Version 1.1\n");
}
}
void loop()
{
Blynk.run();
timer.run();
}