ArduinoLab
PNLProjectsAbout
ArduinoLab

Empowering the next generation of makers and engineers through open-source robotics education.

Platform

  • Explore Projects
  • About Us
  • Login

Organization

  • Pensée Nationale Libre Mahdia
  • Projet SWAFY

Support

  • heythem.94@gmail.com
  • +216 50 126 064

© 2026 ArduinoLab. All rights reserved.

Powered by AI & PNL Volunteers

Developed with ❤️ by Haythem Baganna

Obstacle Avoidance Game using Arduino Uno, Joystick, and LCD I2C
Sensors

Obstacle Avoidance Game using Arduino Uno, Joystick, and LCD I2C

In this project, you will learn how to create a simple obstacle avoidance game using Arduino Uno, a joystick, and an LCD display with I2C communication. The game will challenge the player to navigate through obstacles by controlling a character with the joystick.

Haythem
PNL Mahdia

Step-by-Step Guide

1

Materials List

- 1 x Arduino Uno - 1 x Joystick - 1 x LCD display with I2C - 1 x Breadboard - Jumper wires
Click to expand
Step 1
2

Assembling

1. Connect the joystick to the Arduino Uno: VCC to 5V, GND to GND, and the signal pin to A0. 2. Connect the LCD display to the Arduino Uno: VCC to 5V, GND to GND, SCL to SCL, and SDA to SDA. 3. Connect the breadboard to the Arduino Uno and place the joystick and LCD display on it.
3

Arduino Code & Libraries

The required libraries are LiquidCrystal_I2C and joystick. The Arduino sketch is as follows: arduino

#include

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define OLED_RESET -1 LiquidCrystal_I2C lcd(0x27, SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);

const int joystickPin = A0;

int joystickValue = 0;

int obstaclePosition = 0;

int playerPosition = 0;

void setup() {

lcd.init();

lcd.backlight();

pinMode(joystickPin, INPUT);

}

void loop() {

joystickValue = analogRead(joystickPin);

if (joystickValue < 400) {

playerPosition -= 1;

} else if (joystickValue > 600) {

playerPosition += 1;

}

obstaclePosition += 1;

if (obstaclePosition >= SCREEN_WIDTH) {

obstaclePosition = 0;

}

lcd.setCursor(0, 0);

lcd.print("Obstacle: ");

lcd.print(obstaclePosition);

lcd.setCursor(0, 1);

lcd.print("Player: ");

lcd.print(playerPosition);

delay(100);

}

Click to expand
Step 3

Project Resources

No downloadable resources added yet.

Please login to leave a comment.

1 Comment
Haythem3 months ago

Projet de test !