Arduino PACMAN Game

Arduino UNO 15-02-25
74 0

Tutorial plan

1- Presentation of PACMAN game

2- Objective of our PACMAN Game

3- Required Components

4- Component Wiring

5- Arduino program

 

 

Presentation of PACMAN game

PAC-MAN is a classic arcade game released by Namco in 1980. The game features a yellow, circular character named Pac-Man who navigates a maze, eating small dots while avoiding four ghosts—Blinky, Pinky, Inky, and Clyde. The goal is to eat all the dots in the maze while avoiding being caught by the ghosts. Pac-Man can also eat large flashing dots called "power pellets," which temporarily make the ghosts vulnerable, allowing Pac-Man to eat them for extra points. The game continues with increasing difficulty as levels progress.

 

Objective of our PACMAN Game

The main goal of this Arduino-based PAC-MAN game is to replicate the core mechanics of the original PAC-MAN arcade game while adapting it to work with an Arduino UNO, an LCD screen (I2C or graphical OLED), a joystick, and a buzzer. The player controls Pac-Man, navigating a maze, collecting dots, avoiding ghosts, and using power pellets to gain temporary advantages.

A. Navigate the Maze

The game consists of a predefined maze displayed on an LCD (16x2) or an OLED (128x64) screen.

Pac-Man moves within the maze using the joystick module.

The maze contains:

Walls (#) that Pac-Man cannot pass through.

Dots (.) or small pellets that Pac-Man must collect to score points.

Power Pellets (O) that make ghosts vulnerable.

Ghosts (G) that move randomly or chase Pac-Man.

B. Collect All Dots to Win

The player’s goal is to eat all the dots (.) in the maze.

Once all dots are eaten, the game displays a "You Win!" message, and a buzzer plays a victory tune.

C. Avoid the Ghosts

Ghosts (G) move randomly or follow Pac-Man.

If Pac-Man collides with a ghost, the game ends with a Game Over message and sound.

 

Required Components

Arduino UNO (Microcontroller)

Arduino Uno

The Arduino UNO acts as the brain of the PAC-MAN game. It processes inputs from the joystick, updates the game state, manages collisions, and controls the LCD screen and buzzer.

LCD I2C Screen 

Pinouts of 1602 LCD display with I2C

The display shows the PAC-MAN maze, characters (Pac-Man & ghosts), and score.

Joystick Module (Player Controls)

The joystick allows the player to control Pac-Man's movement in four directions: Up, Down, Left, and Right.

Buzzer (Sound Effects)

The buzzer generates sound effects for key game actions such as eating dots, power pellets, ghost interactions, and game over.

Jumper Wires

Jumper wires

Jumper wires will be used to make connections between the components.

Breadboard:

Breadboard

A breadboard can be used to create a temporary circuit for testing and prototyping.

Component Wiring

Joystick Module:

Connect VCC to 5V on Arduino.

Connect GND to GND on Arduino.

Connect X-axis to A0 and Y-axis to A1 on Arduino.

Connect the joystick button to a digital pin (e.g., D2).

LCD Screen:

Connect SDA to A4, SCL to A5, VCC to 5V, and GND to GND.

Buzzer:

Connect the positive pin to a digital output pin (e.g., D3) on Arduino.

Connect the negative pin to GND.

 

Arduino program

This code initializes the maze, controls Pac-Man's movement, implements a score system, and plays buzzer sounds.

import this library : LiquidCrystal_I2C  for I2C LCD screen

How the Code Works

✔ Pac-Man Moves

Reads joystick values (VRX, VRY).

Updates Pac-Man’s position on the LCD.

✔ Dots (.) Eating & Scoring

If Pac-Man moves to a dot position (.), the score increases by 10.

A buzzer beep plays each time Pac-Man eats a dot.

✔ Ghost (G) Movement

The ghost moves randomly within the maze.

If Pac-Man touches the ghost, Game Over message appears, and a "lose" sound plays.

✔ Game Over Condition

If Pac-Man collides with the ghost, the game stops, and "GAME OVER" is displayed.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info