mamífero
Published © GPL3+

Arduino As A Random Number Generator

Arduino will generate random numbers by receiving an audio signal provided by an FM Radio.

BeginnerShowcase (no instructions)2,132
Arduino As A Random Number Generator

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
For the external circuit it is also needed: 2 resistors of 100k , a 10uF electrolitic capacitor and a device with FM Radio tuner ( per example a cell phone ).
×1

Story

Read more

Schematics

External Circuit

External Circuit

Code

Arduino code

Arduino
Arduino code: open serial monitor to see random numbers
double n;

double randomDouble(double minf, double maxf){
  return minf + random(1UL << 31) * (maxf - minf) / (1UL << 31);  
}
void setup() {
  Serial.begin(115200);
}

void loop(){

   n=analogRead(A0);
   n = n - 512;
    
   if ( n > 0){ 
    n=pow(n,randomDouble(0.00,2.00)); 
    Serial.print("This is your random number: ");
    Serial.println(n); 
   }
   if ( n < 0){ 
    n=pow(abs(n),randomDouble(0.00,2.00)); 
    Serial.print("This is your random number: -");
    Serial.println(n);
   }

  delay(1000);

}

Credits

mamífero

mamífero

6 projects • 12 followers

Comments