24 lines
1.4 KiB
Markdown
24 lines
1.4 KiB
Markdown
---
|
|
title: "Random number generation"
|
|
date: 2015-01-19
|
|
url: random-number-generation
|
|
layout: post
|
|
category: Hacking
|
|
---
|
|
|
|
[![A missing blog post image](/img/blog/random-number-generation.jpg)](/img/blog/random-number-generation.jpg)
|
|
|
|
Here we are !
|
|
|
|
On this project, the idea was to generate a "random" number (note the quotes !) based on some of the information taken out from the environment next to the Arduino.
|
|
|
|
We can fetch the temperature, humidity and pressure (with [BMP085](https://www.adafruit.com/product/391) and [DHT11](https://www.adafruit.com/product/386)), the seconds (with the [DS1302 RTC Module](http://www.hobbytronics.co.uk/real-time-clock-module-ds1302)), the luminosity with a photo-resistor, and the distance between the breadboard and something in front of it (with [HC-SR04](https://www.amazon.com/SainSmart-HC-SR04-Ranging-Detector-Distance/dp/B004U8TOE6)).
|
|
|
|
If a sound is detected (like a 'clap' or something else) (with a [sound detector module](http://www.dx.com/p/arduino-microphone-sound-detection-sensor-module-red-135533#.VMiasy4ppTA)) the program reads data from all the sensors and, with a little function, makes a big _salad_ to get out a number.
|
|
|
|
Once the number is generated, we compute the dispersion rate of all the numbers generated since the launching, and print these two values on the screen.
|
|
|
|
Code ? [Here](https://gist.github.com/HorlogeSkynet/0b723f68da6dcf4c4fcd).
|
|
|
|
Thanks to @thearcanum for the final hashing :+1:
|