Last active
February 28, 2021 16:09
-
-
Save atomgomba/0aae73e957df6b32309aa244c4a1db0a to your computer and use it in GitHub Desktop.
A way to generate a tiny bit more useful random numbers on Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long rand(int min, int max) { | |
long result; | |
for (int i = 0; i < analogRead(A0); i++) | |
{ | |
randomSeed(analogRead(A0)); | |
result = random(min, max); | |
} | |
return result; | |
} | |
long rand(int max) { | |
return rand(0, max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment