Rolling The Dice
There’s only one button, the roll button, which when held down will cause the dice to roll through numbers 1 to 6. After releasing the button the rolling will slow down until the last change where it will instead use a randomly generated number sourced from an XORShift random number generator algorithm (nabbed from here). XORShift algorithms are great for their speed and small code size while still maintaining excellent randomness. The final value flashes a few times, then after a further few seconds the dice turns off.
The dice is powered by a CR1616 coin cell with a capacity of around 50-60mAh.
|State||Current @ 3V|
Some battery life calculations
|Number of rolls||24,000 @ 3 seconds per roll (a quick press of the roll button)|
|Total duration||20 hours|
Rolling the dice 20 times a day should result in a battery life of around 2.5 years.
These numbers are very approximate since the current draw will fall as the battery voltage falls and the LEDs will probably stop lighting up before the battery has completely drained.
Low Battery Warning
The battery voltage is also measured whenever the dice is woken up from a press of the roll button. When the voltage is below 2.4V the center LED will quickly flash a few times to notifiy the user of the low battery before going back to displaying the dice roll value.