TIC TAC TOE

Introduction

The objective of this mini-project is to develop a portable electronic tic tac toe board capable of playing with one player and a microcontroller or two players. Coming up with an algorithm and necessary hardware that would encourage players to play tic tac toe is critical. The finished product will be very user friendly and could be operated without much fuss. Tic tac toe is a game which two players can play. Also known as crosses and zeros, the objective is to mark crosses or zeros (a player marks crosses while his/her opponent marks zeros) on a 3×3 grid and win by getting crosses or zeros in straight lines (horizontally, vertically or diagonally). on. The PIC 16F877A microcontroller from microchip is selected for this purpose as it was pre defined for the practical. The number of I/O ports of the microcontroller would be sufficient to implement the design. The program memory would also be barely sufficient.
Design-Hardware

The unit was designed to be light weight portable and easy to use. Every aspect of the system was designed to be as simple as possible for users to use. The system circuitry was designed using the Orcad software package. Both the schematic and the layout were designed using this software. The gaming unit had to be small and easy to handle the most efficient shape for the unit was a box shape. On top a console was constructed using a pcb board, which included only the switches and LED’s that were required for controlling the unit. The rest of the circuitry was printed on another circuit board that included the PIC microcontroller as well. MPLAB was the IDE that was used in coding and the compiler was HIGH TECH PICC, WINPIC 800 was used to program the microcontroller. The two boards were connected together using ribbon wires. Given below are the rough sketches of the two PCB boards.

The power supply was designed so that the device could be run on batteries. This enabled the device to be used as a portable gaming device. It was designed so that the batteries could be recharged. This was achieved by using a 9v and 5v voltage regulators and diodes. The battery had to be a 6v battery that can be charged from the 9v output of the regulator and the when not connected to a power source, can give an output of 6v to the 5v regulator. The voltage given to recharge the battery was set to almost 6.9v. This was achieved by using 3 silicone diodes with a voltage drop of 0.7v each to get a voltage drop of 2.1v. The schematic diagram of the power supply is given in the attachments section.

The circuit boards,

The Main Board

The Console PCB Board

The PCB s’,

The Layout of the Main PCB

The Layout of the Console PCB
Design-Software

The main algorithm used in this project is a straight forward algorithm that makes choices according to the choices that a user makes. This is done through nested If loops. Separate functions were created for the algorithm of the game, the keypad, checking the choices made and lighting up the LED’s. Another function was used for the two player game. Which type of game is selected is decided in the main function and the relevant function is called. When the game is over, a new game of the same type will be started. To go back to the menu (choosing 1 player or 2 player), the reset button has to be pressed. The list of functions used in the algorithm is given below in the table.

List of functions in the algorithm

Function

Description

Main

Chooses the game type

Game

Game algorithm for 1 player game

Game2

Game algorithm for 2 player game

Greeting

Lights up a sequence of LEDs when called upon

Win

Lights up the all the red LEDs if player 1 wins

Draw

Lights up the all the red and blue LEDs for a draw

Loose

Lights up the all the blue LEDs if player 2 wins

Feedback

Gets the feedback from the user

Choice

Lights up the relevant LED according to the user preference and checks for errors that might have occurred

Results

The final testing of the product showed that all the components and devices were in working order. The algorithm was also working as expected. Further testing showed that there were no hardware or software faults and everything was according to working condition. Given below is a photograph of the device during the testing period.