The game is to be played between two people (in this program between HUMAN and COMPUTER). One of the players chooses ‘O’ and the other ‘X’ to mark their respective cells. The game starts with one of the players and the game ends when one of the players has one whole row/ column/ diagonal filled with his/her respective character (‘O’ or ‘X’). If no one wins, then the game is said to be draw.
Prerequisites
- Windows 10 or above/Linux (64 bit)
- Arduino IDE
- VEGA ARIES Board support package
Hardware Required
This project can be done without OLED display, for that refer tic-tac-toe on serial monitor.
- ARIES v2.0 Board
- I2C 0.96″ OLED Display – SSD1306
- Jumper Wires
- Micro USB type B to USB type A cable
Note: All of the following boards can be used for this project
Libraries Required
Download the Adafruit SSD1306 library and its dependencies from Tools -> Manage Libraries…
Circuit Diagram
Now let’s connect the SSD1306 OLED display module to the ARIES v2.0 board.
Connections
The connection between ARIES v2.0 board & OLED display is as follow.
OLED Display SSD1306 | ARIES V2.0 Board |
VCC | 3.3V |
GND | GND |
SCL | SCL-1 |
SDA | SDA-1 |
Note: If you’re using ARIES v3 board, external PUSH buttons are required.
Procedure
Once we’re done with the connections, let’s power up the board. Make sure the Laptop/Desktop/PC which we’re using should be pre-installed with Arduino IDE and VEGA ARIES boards of latest version.
- Now, Open the Arduino IDE
- Make sure you have selected ARIES v2 Board from Tools -> Board -> VEGA Processor: ARIES Boards -> ARIES v2
- Select Programmer as VEGA XMODEM from Tools -> Programmer -> VEGA XMODEM
- Also select appropriate port, Tools -> Port -> COM* (ARIES Board)
- Open File -> Examples -> Under Examples for ARIES v2 -> Wire -> OLED_SSD1306 -> tic-tac-toe
- Now, Upload the code in ARIES v2 board.
Output
Once the code is uploaded, an empty 3×3 grid will display on OLED, right side of display prints “You” or “CPU”, depends on whose turn it is. It selects the turn randomly. The “?” is a pointer and flashing “?” means it’s the player turn. We can move the pointer to the next empty cell by pressing BTN1 and to select the cell BTN0 is use. The game is played with X and O as the two players’ symbols, where X goes for CPU and O goes for You. A player wins the game if they get three of their symbols in a row (horizontally, vertically, or diagonally). If a player successfully forms a winning pattern, they announce their victory. Press BTN0 or BTN1 to reset the game.