gb.pickRandomSeed
From Gamebuino Wiki
Description
Picks a random seed using a mix of the battery voltage, ambient light sensor and the time elapsed since start up. It should be placed right after gb.begin()
and gb.titleScreen()
, this way the random seed will depend on how long the user takes to press "A" to leave the title screen.
The function is defined in the library as follows:
void Gamebuino::pickRandomSeed(){
- randomSeed(battery.voltage * ~micros() + backlight.ambientLight + micros());
}
The range of values of each part of the function are:
-
battery.voltage
: 4200 to 3500 -
~micros()
: -1 to -4,294,967,293 -
backlight.ambientLight
: 0 to 1024 -
micros()
: 0 to 4,294,967,292
This allows seed values ranging from 0 to 4294964116 (for an unsigned long). Realistically, values are expected to be in the range of 615,970 to 4,293,588,651. (Achieved using a fully charged Gamebuino)
Syntax
gb.pickRandomSeed();
Parameters
none
Returns
none