Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Dino Jump Game with Nokia 5110 LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Dino Jump Game with Nokia 5110 LCD Display

Circuit Documentation

Summary

This circuit consists of an Arduino Nano microcontroller, three pushbuttons, and a Nokia 5110 LCD display. The Arduino Nano is programmed to control the LCD display and read inputs from the pushbuttons. The pushbuttons are used to interact with the system, and the LCD display is used to show visual feedback.

Component List

Arduino Nano

Pushbutton (3 instances)

Nokia 5110 LCD

Wiring Details

Arduino Nano

Pushbutton 1

Pushbutton 2

Pushbutton 3

Nokia 5110 LCD

Code Documentation

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// Pin definitions
#define DINO_PIN 2  // Button for jump
#define SCREEN_WIDTH 84
#define SCREEN_HEIGHT 48

Adafruit_PCD8544 display(10, 9, 8, 7, 6);

int dinoY = 38;  // Dino's Y position
bool isJumping = false;
int jumpHeight = 0;
int obstacleX = SCREEN_WIDTH;
const int groundY = 40;

void setup() {
  pinMode(DINO_PIN, INPUT_PULLUP);
  display.begin();
  display.setContrast(50);
  display.clearDisplay();
}

void loop() {
  display.clearDisplay();

  // Draw ground
  display.drawLine(0, groundY, SCREEN_WIDTH, groundY, BLACK);

  // Dino jumping logic
  if (digitalRead(DINO_PIN) == LOW && !isJumping) {
    isJumping = true;
  }
  if (isJumping) {
    jumpHeight += 2;
    if (jumpHeight >= 12) {
      isJumping = false;
    }
  } else if (jumpHeight > 0) {
    jumpHeight -= 2;
  }
  dinoY = groundY - 8 - jumpHeight;

  // Draw Dino
  display.fillRect(10, dinoY, 8, 8, BLACK);

  // Obstacle movement
  obstacleX -= 2;
  if (obstacleX < 0) {
    obstacleX = SCREEN_WIDTH;
  }
  display.fillRect(obstacleX, groundY - 8, 8, 8, BLACK);

  // Collision detection
  if (obstacleX < 18 && obstacleX > 8 && dinoY > groundY - 16) {
    display.setCursor(20, 20);
    display.print("Game Over");
    display.display();
    while (1);  // Stop game
  }

  display.display();
  delay(50);
}

This code initializes the Nokia 5110 LCD and sets up a simple game where a dinosaur jumps over obstacles. The pushbutton connected to pin D2 is used to make the dinosaur jump. The game logic includes drawing the ground, handling the jump mechanics, moving the obstacles, and detecting collisions.