Final Proposal

 Idea/Concept:

For the final project, I have decided to develop a simple game using p5.js and Arduino Uno. The game is the same as the popular Dinosaur Game by Google. The game involves controlling the dinosaur character by making it jump over obstacles using a button on the Arduino board. To make the game more interesting, the player can also challenge the Arduino board, which will be controlling the button using a servo motor with a tiny hook attached at the end of the motor to press the button.

How to Play Google Chrome Dinosaur Game both Online and Offline -  Studytonight

Serial Communication (Arduino & P5js):

Arduino:

The Arduino board is responsible for controlling the servo motor and reading the status of the game mode selection button and the challenge button. The board communicates with the p5.js game over serial communication.

P5.js:

The p5.js game is responsible for rendering the graphics of the game and communicating with the Arduino board over serial communication. The game receives the status of the dinosaur’s jump button and sends the status of the challenge mode selection button.

Game Modes:

Single player: the user controls the dinosaur jump with a button attached to the Arduino board.

Challenge mode: the user competes against the Arduino board, which controls the dinosaur’s jump using a servo motor. If the user selects the challenge mode, the Arduino board will play first by pressing the dinosaur jump button using the servo motor. The user’s turn starts after the Arduino’s turn. During the user’s turn, the user can press the button attached to the Arduino board to make the dinosaur jump. The user’s score is displayed on the screen, and the game ends when the user fails to jump over an obstacle.

Problems (Training Arduino to play the game):

There’s only one possible problem that I might face while doing this project and that is challenge mode. For the challenge mode to work, I have to train Arduino to turn the servo motor whenever there’s an obstacle. However, I looked on the internet and I think I will be able to train using a simple algorithm on p5.js. The breakdown of the algorithm is as follows:

  1. Use the p5.js pixels array to get the color of the pixels representing the obstacles on the screen.
  2. Check if there are any obstacles present by looking for a specific color in the pixels array.
  3. If an obstacle is present, move the servo motor to press the dinosaur jump button.
  4. Wait for a short time to allow the dinosaur to jump over the obstacle.
  5. Release the servo motor to allow it to return to its initial position.

Hopefully, this will fix the issue. It might require a lot of testing for the motor to match the time of the obstacles appearing on the screen.

Leave a Reply