Tinkercad Tic Tac Toe
As a child, we all have played and loved the Tic Tac Toe game. Before mobile phones hit the masses and games can easily be downloaded from the Playstore, for me, this was one of my favorite games that I can play anywhere from the classroom to trains to my home to kill time and boredom.
Here I'm sharing how we can easily this classic game on Tinkercad.
Supplies
- Tinkercad account(It's Free)
- Computer with Internet connection.
Setting Up the Micro:bits
Log in to your Tinkercad account and click on the circuit button at the left of your screen. At the left of your screen search for Microbit under the Basic category.
Drag 6 Mircobits onto the workspace and arrange it as shown in the picture above.
For easier reference, we will call the Micro: bit at top left as Micro: bit 1 and micro:bit at its right as "Micro: bit 2" and so on
Programming the Micro:bit 1
- Click on the "Micro:bit 1" and then click on to the Code. Notice that there are two blocks, "on start and "Forvever", are already present there. Delete the forever block.
- Grab a "show led' block from the "output" and place it inside the "on Start' block.
- Start clicking on the grids of the "show led" block so that it shows the alphabet "T" of the English letter. This code runs every time the game starts/restarts. So every time the game start/restart, the "Micro:Bit 1" will always display the "letter T".
- Now, go the basic and drag out an "on button A pressed' block to the workspace. This will help us to program the button on the Mico:Bit.
- Next, snap a "show led" block and place it inside the "on button A pressed". Click on the grids and make an X on the grid. So, now every time button A is pressed, the Micro:Bit will display X. Drag another "on button B pressed" block and repeat these steps to display O when button B is pressed.
- We also want this Micro:bit to send a message to all the other Micro:bits to Clear their respective screen whenever we shake this Micro:Bit. To do this we will bring out an "on shake" block and then insert a "radio send number 1" block from the Output, inside the "on shake" block.
- Finally, look for the "clear screen" block under the "radio send number 1"
Programming Rest of the Micro:bits
We will program rest of the Micro:Bit in a similar manner as we have done in the previous step. There is 2 major differences that we have to make sure of. These are:
- While programing the "show led" block for the "on start", Make sure that each Micro:Bit is displaying the letter of the word TIC, TAC, TOE. Please refer the image above.
- To program the Micro:Bit to delete the content on the screen when "Micro:Bit 1" is shaken, we need to use "on radio received number" instead of "on shake" block. You can find this block under Inputs. Now, inside this "on radio received number" block we place an If-then statement block to clear the screen when it receives the radio signal from "Micro:bit 1".
How to Play
Our Game is ready to play. Click on the "Start Simulation". Now share the mouse with your partner to choose between 0 or X, clicking the button A or B. You can clear the screen and start afresh by clicking on "Micro:bit 1"