Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2026:jan.vaduva:bogdan.ciupitu [2026/05/15 14:16]
bogdan.ciupitu
pm:prj2026:jan.vaduva:bogdan.ciupitu [2026/05/15 14:34] (current)
bogdan.ciupitu [Introduction]
Line 3: Line 3:
 ===== Introduction ===== ===== Introduction =====
  
-**Dual-Controller OLED Tic-Tac-Toe** is a portable handheld gaming device specifically designed for two players. This project brings the classic game of Tic-Tac-Toe to a custom electronic platform built around an Arduino Uno board.+**Dual-Controller OLED Tic-Tac-Toe** is a portable handheld gaming device specifically designed for two players ​or player versus bot. This project brings the classic game of Tic-Tac-Toe to a custom electronic platform built around an Arduino Uno board.
  
 **Project Goals:** **Project Goals:**
Line 57: Line 57:
  
 **Adafruit_SSD1306**:​ Essential for handling the display buffer and I2C communication protocol for the SSD1306 OLED. **Adafruit_SSD1306**:​ Essential for handling the display buffer and I2C communication protocol for the SSD1306 OLED.
 +
 **Adafruit_GFX**:​ Provides the graphics core for rendering lines, circles, and text characters. **Adafruit_GFX**:​ Provides the graphics core for rendering lines, circles, and text characters.
 +
 **Wire.h**: The standard Arduino I2C library used for data transmission between the MCU and the display. **Wire.h**: The standard Arduino I2C library used for data transmission between the MCU and the display.
  
 ==== Algorithms and Data Structures ==== ==== Algorithms and Data Structures ====
 +
 **2D Array Representation**:​ The game board is stored in a int board[3][3] matrix, where $0$ is empty, $1$ is '​X',​ and $2$ is '​O'​. **2D Array Representation**:​ The game board is stored in a int board[3][3] matrix, where $0$ is empty, $1$ is '​X',​ and $2$ is '​O'​.
 +
 **Threshold Detection Algorithm**:​ Analog joystick values ($0-1023$) are processed using a hysteresis-like logic ($<300$ and $>700$) to prevent "​ghost"​ movements. **Threshold Detection Algorithm**:​ Analog joystick values ($0-1023$) are processed using a hysteresis-like logic ($<300$ and $>700$) to prevent "​ghost"​ movements.
 +
 **Win-Check Algorithm**:​ A deterministic function that scans 8 possible vectors (3 rows, 3 columns, 2 diagonals) for identical non-zero values. **Win-Check Algorithm**:​ A deterministic function that scans 8 possible vectors (3 rows, 3 columns, 2 diagonals) for identical non-zero values.
 +
 **Randomized AI Logic**: A pseudo-random selection algorithm that identifies available indices in the board matrix to perform automated moves. **Randomized AI Logic**: A pseudo-random selection algorithm that identifies available indices in the board matrix to perform automated moves.
  
 ==== Implemented Functions ==== ==== Implemented Functions ====
-setup(): Initializes I2C communication,​ sets pin modes for joysticks, and seeds the random generator using noise from an open analog pin (A5)+**setup()**: Initializes I2C communication,​ sets pin modes for joysticks, and seeds the random generator using noise from an open analog pin (A5).
-drawMenu(): Handles the UI for mode selection (Single Player vs Multiplayer) and processes Joystick 1 input for navigation. +
-tttGameLoop():​ The core engine that manages turns, calls the input mapping functions, and updates the game state. +
-botMove(): Implements the automated opponent logic with an artificial delay to simulate human-like interaction. +
-checkWin() & checkDraw():​ Logic functions that return boolean values to trigger the end-of-game state. +
-drawTTTGrid():​ A dedicated rendering function that draws the board lines and iterates through the matrix to display X and O symbols. +
-playVictorySound() / playDrawSound():​ PWM-based functions that use the tone() command to provide audio feedback through the buzzer.+
  
-===== Results =====+**drawMenu()**:​ Handles the UI for mode selection (Single Player vs Multiplayer) and processes Joystick 1 input for navigation.
  
 +**tttGameLoop()**:​ The core engine that manages turns, calls the input mapping functions, and updates the game state.
  
 +**botMove()**:​ Implements the automated opponent logic with an artificial delay to simulate human-like interaction.
  
-===== Conclusions =====+**checkWin()** & **checkDraw()**:​ Logic functions that return boolean values to trigger the end-of-game state.
  
 +**drawTTTGrid()**:​ A dedicated rendering function that draws the board lines and iterates through the matrix to display X and O symbols.
  
 +**playVictorySound()** / **playDrawSound()**:​ PWM-based functions that use the tone() command to provide audio feedback through the buzzer.
  
-===== Source Code =====+===== Results ​=====
  
 +The project resulted in a fully functional handheld console. The system successfully handles real-time input from two controllers without latency. The OLED display provides a clear interface, and the integrated Bot offers a challenging solo experience. The memory optimizations (using the F() macro) ensured the system remains stable during long play sessions.
 +===== Conclusions =====
  
 +//todo//
 +===== Source Code =====
  
 +
 +//todo//
 ===== Bibliography/​Resources ===== ===== Bibliography/​Resources =====
  
 +==== Software Resources ====
 +
 +Adafruit GFX Library Documentation https://​cdn-learn.adafruit.com/​downloads/​pdf/​adafruit-gfx-graphics-library.pdf
 +
 +Adafruit SSD1306 Library https://​github.com/​adafruit/​Adafruit_SSD1306
 +
 +Arduino Reference - Tone Function https://​docs.arduino.cc/​language-reference/​en/​functions/​advanced-io/​tone/​
 +
 +Arduino Reference - RandomSeed https://​docs.arduino.cc/​language-reference/​en/​functions/​random-numbers/​randomSeed/​
 +
 +Memory Optimization (F macro) https://​docs.arduino.cc/​language-reference/​en/​variables/​utilities/​PROGMEM/​
 +
 +==== Hardware Resources ====
 +
 +Atmel ATmega328P Datasheet https://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf
 +
 +SSD1306 OLED Controller Datasheet https://​cdn-shop.adafruit.com/​datasheets/​SSD1306.pdf
 +
 +Joystick Module (KY-023) Guide https://​arduinomodules.info/​ky-023-joystick-dual-axis-module/​
pm/prj2026/jan.vaduva/bogdan.ciupitu.1778843808.txt.gz · Last modified: 2026/05/15 14:16 by bogdan.ciupitu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0