Smart Dice Tower with Arduino [Board Game Assistant]

Have you ever played board games? Do you like to play with dices? We use dices in many board games, but sometimes they cause problems. For example, when I play a thriller with friends, sometimes we forget the turns. Do you want to know how you can solve this problem? If so, follow this article.

We want to show how you can build a smart assistant with electronic components, such as the KY-037 sound detection module, RGB LEDs, TFT LCD shield and of course an Arduino UNO.

What You Will Learn in This Article

  • What a dice tower is, and how we can make one
  • How to use sound detection module to know when dices are falling
  • How to use an RGB LED to show turns and add a light effect
  • How to use an LCD to display more information and create a virtual dice

What is the Dice Tower?

Many board games use dices. To those who prefer real games to computer ones, it is essential to hold and toss the dice(s). But there is no guarantee for justice and players might cheat! Besides, some board games have a lot of dices. Tossing several dices at the same time can be difficult, and some might even get lost.  A dice tower is an excellent idea to solve these problems. Dices enter from above the tower, touch inner plates and spiral down to settle in the bottom.

Arduino and dice tower

Board Games: More Charm, Less Cheat!

No matter the game, cheating is always a possibility; especially games with dices. Thrill and pace of the game might confuse players about turns. Therefore, the presence of a fair judge can be helpful. With some electronic innovation, we can make a smart dice tower to help keep turns and display it in colorful lights.

You might lose a dice during the game. So you are obliged to use a different object (a stone!) instead of dice. A smart dice Tower gives you the best option. Even if there’s nothing around to use as a dice, have no fear, our tower has a virtual dice.

Required Materials

Hardware Components

Arduino UNO R3×1
2.4" TFT LCD Display Shield×1
KY-037 Sound Detection Sensor Module×1
5mm RGB Tri-color 4Pin LED - 20 Pcs×3
3 X 1.5V AAA Battery Box Holder with cover and ON-OFF switch×1
1.5V AAA Battery×3
330 Ohm Resistor×3

Software Apps

Arduino IDE

How to Assemble Dice Tower’s Body

To make a Smart Dice Tower, first, we need to build the body. It can be made of 2.8mm MDF or Plexiglass. Feel free to download the laser cutting draft here:

The designed dice tower has 58 parts. You can assemble them using super glue, according to the following video.

This 3D view of the dice tower can be very helpful:

Dice Tower Mechanical Assembly Video

Note

Some draft parts are spare parts and won’t be used.

Smart-Dice-Tower-mechanical-component

Circuit

We use an Arduino TFT LCD shield in this project. To operate this module, just mount it onto Arduino UNO (note pins position and orientation). In order to set up the KY-037 module, connect the supply pins of the module to the VCC and the GND pins and the digital output pin to pin D13 of the Arduino.

To use RGB LED, connect the cathode pin to the GND pin of the Arduino and connect the red, green and blue pins to D5, D6 and, D7 on the Arduino board.

See the following video to see how to assemble the electronics parts:

Dice Tower Electronics Assembly Video

How to Use Sound Detection Module to Know When Dice Is Falling

We can use a or sound detection module to know when a dice is falling. If we put the knock sensor under one of the inner plates, the given shock won’t be enough. Putting the sensor directly in the path of dice is not right either. So a sound module is a proper choice. We can setup the KY-037 sound module simply according to picture 4. Since there is just one tone to detect in this project, we just use the digital pin of the sound module. To recognize dice sound, we can read the D13 pin of the Arduino (which is connected to the digital output of the sound module) with the digitalRead() command. The Digital pin is pulled up in this module, and when a sound reaches the threshold, the digital pin voltage will become zero. We can change the sound threshold by turning the potentiometer on the board. To calibrate this sensor precisely, follow these steps:

    1. Upload the following code to your Arduino board:


2. Open Serial Monitor Now frequently drop the dice in the tower, while turning the potentiometer until you see number zero in the Serial Monitor window. Throw in the dice a few more time to make sure module is well adjusted. It should be tuned so that other noises in the environment wouldn’t activate the sensor.

For more information on KY-037, visit this article.

How to Use an RGB LED to Show Turns and Add Light Effect

There are various RGB LED types. We use the 4-pin common cathode RGB LED in this project. To turn on the LED, we should connect the cathode to the GND. And adding voltage to the other pins will turn LED red, green or blue. If all three pins are set to high, LED will glow white.

Tip

You can use the PWM signal with the analogWrite command to create different color spectrums with RGB LED.

Using the following code, you can periodically change LED color to red, green, blue and white.

Using a TFT LCD to Show More Information and build a Virtual Dice

To show a player’s turn, we should know the number of players and their corresponding color. We can use a TFT LCD with a touch screen. The 2.4-inch Adafruit LCD shield for Arduino is an excellent simple choice.

See the full tutorial for this LCD here.

In the following code when starting up the LCD, first the number of players is asked and the user can choose it from 1 to 4 by touching the dice on the screen. Based on the number of players, it asks a color for each player. At the end of this part, the color sequence is displayed and then the game starts.


After the program receives the number of players and their colors, it starts the main code. With the KY-037 sound module, dice falls are counted and stored in the count variable. The count will then be divided by the number of players, and the remainder will show the next turn. Each turn, LCD displays the player’s color and waits until he/she throws the dice. When dice falls, the RGB LED shows random colors, and LCD plays a simple dice animation.

LCD right side displays overall toss-drop count.


This part of code shows dice number using Dice (number) function.

To make the game more interesting, you can use pictures instead of colors. Save the images you like in a micro SD card and put it into an SD card slot. The following code reads images from the SD card.


Put this functions at the end of main code and replace bmpDraw(c[t], 0, 0); line with tft.fillScreen(c[t]); throughout the code. Then, by each turn, LCD shows player’s image instead of a color.

Variable c[t] should be a string with a length of at least 10 characters. It contains the names of the pictures on the SD card.

All pictures on the SD card must be 320×240 pixel and bitmap 24-bit format. For example, you can use photos in this zip file for your dice tower.

Add Virtual Dice and upload final code

Now that our LCD shows several dices, we can have a virtual dice. Add the following code at the beginning of the void loop().


Once code is copied, a new button named as virtual dice appears on the left side of the LCD. Touch the button to activate virtual dice. At the center of LCD, dice starts to change randomly and then pauses for 2 seconds. To insert this pause into code, replace the code of LCD dice animation section with the following code:

You can download the complete code for the dice tower from the following link. You must calibrate the touch screen before uploading this code to the Arduino board.

Touch Screen Calibration

To calibrate the touch screen, upload the following code to your Arduino board.
This code will ask the user to touch certain areas displayed on LCD to calibrate the touch screen. After you touch all red dots, LCD will give the marked area coordinates to insert into the main code. You can view these coordinates in the serial monitor window too.


First, upload the above code to the Arduino board. After running the code, touch the displayed red dots. Replace values for TSx_dices, TSy_1st_dice, TSy_2nd_dice, TSy_3th_dice, TSy_4th_dice, TSy_virtual_dice at the beginning of the original code with numbers in the serial monitor or on the LCD in the last step.

What’s Next?

  • Change the virtual dice program so that rolling a 6 will be rewarded with another dice roll for the player.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *