Skip to content

Instantly share code, notes, and snippets.

@atomgomba
Last active February 28, 2021 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomgomba/0aae73e957df6b32309aa244c4a1db0a to your computer and use it in GitHub Desktop.
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
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