Skip to main content
Version: ACS CC

2048 game

Implementation of the famous game 2048.

info

Author: Diaconu Alexandra-Ioana
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-AlexDia10

Description

The project consists of an implementation of the famous game 2048. The goal of the game is to reach the value 2048 by combining powers of 2 on a 4x4 board (classic mode). The player combines numbered tiles by moving up, down, left and right, using physical buttons. The game runs on a Raspberry Pi Pico 2 and is displayed on a color LCD.

  • The system utilizes five buttons for the gameplay: up, down, left, right and reset.

  • The LCD screen showcases the grid and the numbered tiles.

  • A buzzer that makes a sound when a milestone is reached.

Motivation

As a kid, I loved playing simple, clever games like 2048, fascinated by how such a basic concept could be so addictive and satisfying. That experience stuck with me and inspired this project: building my own version of 2048 from scratch.

While planning the system — from managing inputs to handling graphics and game logic — I realized it’s more than just code. It’s also about creating a smooth, engaging experience, which taps into my love for design and user interaction.

Architecture

The Raspberry Pi Pico 2W serves as the central control unit, directing and managing all other components utilized within the project.

The LCD serves as an interface for showcasing the grid and numbered tiles, it is connected to the Pico through SPI

The buttons act as the primary input method, they are connected directly to the Pico's GPIO pins

The buzzer emits sound cues for actions and is connected to a GPIO pin

diagrama

Log

Week 5–11 May

Conducted individual testing of all hardware components to ensure functionality and reliability.

Week 12–18 May

Finalized and verified all hardware connections.

Performed integrated testing of all components working together.

Initiated development of the core game logic.

Updated project documentation to reflect the final hardware schematic.

Week 19–25 May

Achieved significant progress in implementing the game logic.

Identified and resolved several logic-related issues.

Enhanced documentation by including a list and explanation of the libraries utilized in the project.

Hardware

  1. Raspberry Pi Pico 2W:
  • Purpose: Controls all components.
  • Function: Acts as the main controller, coordinating the operations of buttons, buzzer, and the LCD display.
  1. LCD Display:
  • Purpose: Displays the grid and numbered tiles of the 2048 game.
  • Function: Provides a visual interface for the user, updating the display dynamically as the user moves the tiles and merges them.
  1. Buttons:
  • Purpose: Serve as the user input method for controlling the game.
  • Function: Allow the player to move tiles in four directions (Up, Down, Left, Right) and reset the game.
  1. Buzzer:
  • Purpose: Provide auditory feedback during gameplay.
  • Function: Emits sound cues for actions such as tile merges, successful moves, or game over.

Top view

Screen front

Schematics

schematic

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2WThe microcontroller39,66 RON
LCD DisplayLCD Display27,99 RON
ButtonsPush Buttons5 x 0,36 RON
BuzzerActive Buzzer0,99 RON

Software

LibraryDescriptionUsage
embassy-executorAsync executor for embedded systemsSpawns and runs async tasks (Spawner)
embassy-timeTime and delay utilities for async embedded appsUsed for Delay, Timer, and Duration utilities
embassy-syncAsync synchronization primitivesProvides Mutex and Channel for safe inter-task communication
embassy-rpEmbassy driver support for RP2040Provides GPIO and SPI peripheral access (gpio::Output, spi::Spi)
embassy-embedded-halHardware abstraction traits for embedded devicesProvides SpiDevice trait for shared SPI interface
display-interface-spiWrapper to convert SPI interfaces to display interfacesAdapts SPI bus to a display driver interface
mipidsiDriver for MIPI DSI compatible displays like ST7735Drives the ST7735 LCD over SPI (Builder, Orientation, etc.)
embedded-graphics2D graphics library for embedded devicesRenders text and shapes on the LCD (Text, Rectangle, Rgb565, etc.)
randRandom number generator and utilitiesGenerates pseudo-random numbers via SmallRng