← Back to projects
Robotics · AI · Mechatronics

Connect 4 AI Robot

A fully autonomous robotic arm that plays Connect 4 against a human opponent — Python AI decides the move, MATLAB kinematics computes the position, Arduino executes the motion.

Context
Academic Project
Year
2024
Category
Robotics · AI · Mechatronics
Role
Full project — mechanical, electrical, software

Overview

Connect 4 is a two-player game where players drop colored pieces into a vertical grid, aiming to form a line of four in any direction. This project builds a robotic arm capable of playing the game autonomously — thinking strategically, choosing the best column, and physically placing a piece in the correct position.

System Architecture

Python AIGame logic + decision
Serial (USB)Move commands
Arduino MegaMotor control

AI & Game Logic

The game environment was built in Python using Pygame. The AI evaluates board states using a minimax-style scoring function to select the optimal column for each move. Once a move is selected, the column number is sent over serial to the Arduino.

Robot Control & Kinematics

The robotic arm was modeled mathematically in MATLAB using Denavit-Hartenberg (DH) parameters to define the workspace and joint configurations. Each column of the board corresponds to a known set of joint angles, calculated through inverse kinematics and stored as target positions in the Arduino firmware.

When the Arduino receives a column command via serial, it calculates the required motor steps and drives the arm to the correct position to drop the piece.

Electrical Design

The electrical system was fully designed and documented — power distribution, Arduino Mega, stepper motor drivers, sensors, and actuators. The schematic covers all connections from supply to actuators.

Results

  • Fully functional robot capable of playing complete Connect 4 games autonomously
  • Seamless integration between AI decision-making and physical execution
  • Accurate arm positioning across all 7 columns of the board
  • Complete system: mechanical design, electrical schematic, kinematics model, and software