Introduction: Soft Toy Bluetooth Dice and Develop Android Game With MIT App Inventor

Playing dice game has different method

1) Traditional playing with wooden or brass dice.

2) Play in mobile or pc with the dice value random created by mobile or pc.

in this different method play the dice physically and move the coin in the mobile or PC. We able to find tiny bluetooth dice on online store. But here we use this toy for multiple purpose used as soft toy for Toddler and used as Bluetooth dice for younger.

Also develop a android game support he bluetooth dice. I use MIT App inventor to develop small application for instructables. Here i explan in detail steps how i develop a game name "Black Hole and Space Ship" (like Snake and Ladder) and the player name as Wall-E and EVE so its "WALL-E and EVE in Black Hole and Space Ship" even with out bluetooth dice you able to play this game. For only game development please got to Step 9 directly.

Step 1: Materials Required

Materials Required

1) Arduino Nano - 1 No.

2) MPU6050 - Triple Axis Gyro Accelerometer Module - 1No

3) HC05 Bluetooth Module - 1No.

4) Push ON/OFF Button - 1No.

5) 9V battery - 1No.

6) 9V battery Connector - 1 No.

7) Plain PCB.

8) Male Female header pins.

9) Corrugated Board.

10) Sponge.

11) Velvet Cloth.

Step 2: Circuit Development

For Arduino projects develop circuit is always very interest for me. Here a very simple connection.

Power supply for Vin is given from 9V battery through a puch ON/OFF Button.

I always Connect the HC05 to Arduino Tx, Rx but here in this project it is connected to D4,D3 and use it as software serial to connect. Reason for the change is after pack the circuit in the dice and change the code cant able to remove HC05 from the circuit, if hc05 is present cant able to upload the code. so change to Pin 4,5.

MPU6050 Vcc and GND connected to Nano 5V and GND. Connect the SDA of MPU6050 to A4 and SCL to A5.

Make a Small shield as possible. Keep MPU6050 in straight position in any direction. Now the circuit is ready. Check with sample program and calculate the angle.

Step 3: Make Square Box 3 Inch With Fill Boards

Make a 3 inch X 3 inch X 3 inch box using single ply corrugated board. Its very easy to make a box, lot of ways. I use the single sheet to create the pattern and paste it with fevicol (gum). Keep one side open. Cut 3 inch X 3inch pieces to fill the box, for me it take 17 pieces to fill. This fill pieces hold the circuit in the same position.

Step 4: Fix the Switch

Fix the switch in the corrugated box. Mark the center of the box in the opposite side of opening and draw a circle. Use pin cut the hole to hold the switch. Now in insert the fill corrugated pieces in the box and using marker mark the hole place in the fill pieces. Remove the fill pieces and take slot in the pieces with marker marks. and check the switch back portion is fit.

Step 5: Take Slots in Fill Boards for Circuit

Leave the center, slot taken pieces and take the remaining left side and right side pieces and take slot for circuit and battery. The Slot must hold the circuit and battery tight, but able to remove it easily. Keep the arduino usb connector out side so that we able to change the program just bu open the dice. Main thing is keep the MPU6050 straight to any position. Remove the circuit and glue (i use fevicol) all the sheets together and allow to dry. Now the circuit holding part is ready.

Step 6: Finish the Basic Dice

Change the power supply wiring with long wire. Take two wire from switch. Insert the wire through the slot and connect one end to positive of battery holder and other to the Vin of the Arduino uno. From negative-ve of the battery direct to the gnd of the arduino. Connect the battery and keep the battery inside now the basic dice structure is ready.

Mark numbers in pencil on sides. Butten side is 1 and its opposite side is 6. Refer Wikipedia for basic dice sides and mark it in the dice.


Currently Dice in 1 side not flat on the floor while adding sponge this side is corrected.

Step 7: Check the Angle for Dice

Open the card board dice and connect the wire to the arduino. Using sample code find the Angle of XYZ of MPU6050. Make a spread sheet and mark the angle shown in each side. Take the reading and create a range of XYZ on each direction. Use that range determine the sides of the dice.

Step 8: Arduino Program

Download Program for Arduino from google drive by click here

In the program use Wire library to connect with MPU6050, Use Software serial library to connect to HC05. From Wire library Request response get the reading from the MPU6050 and with calculation find the angle of XYZ (calculations taken from web). As per early step with the angle calculate the dice side. From android when receive OK at first the dice wait for 2 cycle then check for the current postion 3 times, if the position is same for 3 times then it send the current side to android. So with out rotate the dice side is not send to android.

Step 9: Start Create App in MIT App Inventor


Come and sit in front of the sheet because its time to develop a android Dice game. I choose snake and ladder game with two player.

MIT APP INVENTOR is a online android app developer with visual programming interface. Its very easy to develop app. Lot of help resource found in the net. Here we see some basic steps before go to game development.

Open the link given above go to the App inventor web page. Click create app in the left side and it go to sign in with google. Give your google account user name and password and sign in. It go to your list of projects. I did lot of small apps for instructables. Click the button create new project and in the input box give the project name and click ok and it direct you to the development page.

Step 10: Basics of MIT App Inventor

Designer Screen

In the Development page we have two sides one is designer side and Blocks side. By click the button we switch the sides. In the designer view one side is palette and the other side is properties, Components and Media. From the palette you drag and drop the components to the active form. If a component is selected in the form the property of the component is listed in the properties, you able to change the properties. In the components list, listed the components used in this project. By click the name in the component list also select the component, also change the name by click rename or delete it by click delete button in the bottom.

In the top side you found a add screen button, by click the buton a input box ask the new screen name, enter the name and click ok, new screen created. List of screen in the project is listed in the button next to the add screen button by select the screen move to that screen in the designer. To remove the screen click the remove button.

In the Media Click upload file and from the popup screen click choose file and select the file in the computer to upload and click ok. To add images sounds to the project use this method.

Blocks Screen

In the Blocks screen, in the left side components added in the project is listed. By click the Component name the slide menu shows the list of commands for the components in blocks, just click and drag that command to the design area and like it. Built in commands and variable declaration has separate Buit in menu.

Step 11: Wall-E and EVE First Screen

Let start our Coding. Its a traditional snakes and ladder, i name it as Blackhole and Space Shep and include the players name Wall-E and Eve in Blackhole and Space.

In the Front screen Just the title and Play Button. By click the Play button move to game screen.

In the Blocks side you able to see the command in just two set of blocks.

Step 12: Game Screen

Designer Screen

In the designer screen we have two layout one with the game items and another with the game ending. On load hide the Game end layout. At the end hise the first layout and visible the game ending layout with the image of the winner (Wall-E or EVE). Keep the orientation of the screen as portrait.

Photoshop Design a image with 10 X 10 blocks in photoshop and number all the blocks from 1 to 100 as shown in the figure (movement for snake and ladder game). As per your like give color and set background. Plan the blocks from and to for Snakes and ladders. Add black hole in image in the bottom of black hole start point and end image in the top of the end point, connect between this two at each black hole points. In Space ship taken point put a space ship image on the top and in the drop point plat form.

Add a canvas in the Game layout and add two image spirit one with Wall-E image and another with EVE image and set properties visible to false. In the bottom add image for Dice, Player 1 image with a label to show Current position, A Dice image, Player 2 image with a label to show Current position.

Add three Clocks, Notifier and Bluetooth client for program support.

End Layout contain a Image to load the winner image and a button to restart the game.

Blocks Screen

In the Blocks contain the coding for the Dice random generation if not connected to Bluetooth while click the dice image, If connected to bluetooth dice value from blue tooth dice taken. Move the player as per the dice value. Step in to game only after put 1 in the dice. If put 1 or 6 replay option and if space ship taken to the top another replay, If black hole bring to down no replay. Who first reach the 100 is the winner. See the coding step by step.

Step 13: Game Start Blocks

In the game start i created a procedure startgame and call the procedure when screen intialize. In the Procedure disable the clock and set the current position of players to 0. Set the image in the canvas visible false and move it to the 1 st block of the game. Set which player turn to the first player. Call another procedure sendcommand, in that procedure if connected to bluetooth then send OK. set thr current background of the player going to play in green.

Step 14: Blue Tooth Connection

Use the Bluetooth client to make connection with the arduino. Function Before picking in Blutooth listed the paired bluetooth devices. On Click the selected blue tooth After Picking executed and if the connection is ok then the bluetooth button disable and clock3 enabled. Send a command OK through bluetooth. If any error in bluetooth while running then enable bluetooth button and disable clock3. Clock 3 timer is used to watch the data receive from the bluetooth after connected, if receive dice value it go to the player movement.

if Dice is click the dice move random and stop as one point and its the dice value if not connected to the bluetooth. Clock 2 used for dice rotation and get random number from 1 to 6. If connected to bluetooth then dice value from arduino.

Clock 1 used to move the player step by step. Example if you in pos 10 and put 5 then it want to increase step by step 11,12,13,14,15. So clock 1 control it and call procedure move coin and check the postition.

Step 15: Step Conditions and Move

Now the dice is put and value is taken and coin is moved. And the player is in a postion in the grid. Say in 18.

After movecoin procedure, checkmove executed. It has a list of if condition for example (if coin is in 18 then move the coin to 45 and allow the player for another turn) like wise for hole move it reverse and get the point. Then move that palyer coin to that position.

In the Calcelpos procedure find the X and Y position of the cell by divide the width of the canvas by 10 and multuply with the col of the current cell. Like wise for height divide the height with 10 and multiply the row number of the current cell.

Movecoinloc procedure, as per player, move the player coin to the pos calculated in Calcelpos.

Step 16: Color Change and Dice Image Change

While clock2 run as per random number generate change the image in the dice and when stop show the current dice value image. Change the player background color to green who want to play and oragne who not play. Create procedure for that and call the procedure at each dice play.

Step 17: End Game

If the player current value is 100 then call the End game procedure. In the End game procedure hide the game layout and show the end layout. If player 1 wins show their image and hide the player 2 image.

Step 18: Create App

Download the MIT AI COMPANION from play store.

Open the app in the mobile.

In the MIT developer web page click build menu and in the drop down menu click APP(provide QR code for .apk). After few minutes of processing shows the QR code.

In the mobile click Scan QR code in the MIT app and scan the QR code in the PC and it directly download the app and ask permission to install. Give permission and install the app.

If you want apk file in the computer click build menu and in the drop down menu click APP(Save .apk to my computer). After few minutes of processing complete and apk file download in the computer.

Step 19: Play Game in Android

Download apk file from Google Drive by click here

Download aia file from Google Drive by click here

For those who not interested in programming just download the apk file from the link and install it in the mobile.

Turn on bluetooth in the mobile. Click the Black hole and space ship icon one the mobile. Click play in the welcome screen.

Play with Blue tooth Dice

Click bluetooth button on the down corner of the game and it listed the available blue tooth select the arduino blue tooth. Now the connection made, Roll the dice to plat game.

Play with out Blue tooth Dice

Click the Dice image on the bottom center of the screen and it random generate the dice value and the game is playing.

Step 20: Dice Sponge Layer

Now Dice is in card board and it cant able to through for multiple times and also push button on one side. So make a sponge box which fit the card board dice. the card board box is 3inch X 3inch X 3inch, i extend 0.75 inch in all sides. So the sponge box is So the Sponge box is 4.5inch X 4.5inch X 4.5inch. Songe box is center open so we able to change the battery if failure.

Step 21: Cover With Velvet Cloth and Paste Dots

I have Red velvet cloth. Just like card board box make a cover of size 4.5inch X 4.5inch X 4.5inch and in the top put a ZIP to put the sponge box in. Cut 21 X 25mm dia circles and use fabric glue to stick in sides as per position noted in card board. Insert the sponge box into the cover and zip it. Due to sponge all sides we able to switch on and off from out side. In the Dice number 1 side press the 1 and release switch on the dice, press it again switch off the dice. Now the Dice is ready and the game is ready Lets play and have fun.

I design it for two player game, if want more player games change the android program by just download the aia file given in android program step and open it in the MIT App inventor.


Be careful while stick the dots verify one or two times. Because i wrongly paste 6 and 4. Only after photo and play i see it and remove the two from 6 and paste it on 4.

Step 22: Fun With Play

Kids like to play with soft toys and if you play game with soft toy its more fun. Through the Soft toy dice over other is also fun. My Kid like this game very much even before make bluetooth dice she play the game lot of times with us. Have fun with kids with fun items like this.

I enjoy a lot on making in this project. same words again, I lean some new things from this project, I feel you also learn some small thing on reading this project. Thank you all for reading it.

Lot more to enjoy...............Don't forgot to comment and encourage me friends.

Toys and Games Challenge

Participated in the
Toys and Games Challenge