Includes long LED, bright LED, and light wire. Shop Now
*Free bundle on purchases greater than $100 only.
Many games involve tossing a pair of dice. Here is a littleBits Arduino sketch that simulates tossing a pair of dice for two players. Of course, if there are more that two players, then the dice can be shared, as in any game with real dice. Each player simply pushes his or her button, and the results of the toss of the pair of dice are displayed as the two digits on a number module.
Click on the m4v movie file below to see littleBits "Dice" in action.
See the alternate image on the left for which each player has a mounting board with his/her button and number module attached.
Construct the circuit shown in the picture. Note that the Arduino module's micro-USB cable must be connected to your computer, and the computer must have the Arduino IDE software installed. The number modules should be set to "values" (not "volts"). THE ARDUINO SWITHCES SHOULD BOTH BE SET TO ANALOG. Set the dimmer switch to a random position each time before you load the sketch--this will make the odds high that you will get different dice toss results each time the Arduino with this sketch is powered up.
Power up the Arduino module. Start the Arduino IDE software. Select Tools>Board>Arduino Leonardo. Then select Tools>Serial Port and select the serial port that the Arduino will use for communication. This will depend upon whether you are using a Windows, Mac, or Linux machine. Open the sketch file called Dice.ino. Upload the sketch to the Arduino module. After it is loaded you will notice that both number modules read 00. Each player can now toss his or her dice by pressing his or her button.Once you have loaded the Dice.ino program to the Arduino module, you can disconnect the circuit from your computer, and run the dice program wherever you wish!