Skip to main content
Version: FILS English

Catch the falling apples

A remake of a classic arcade game where you catch as many apples as you can

info

Author: Radu Ana-Maria-Gabriela
Github Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-anamariaradu6

Description

“Catch the falling apples” is a classic arcade game controlled by the STM32 Nucleo-U545RE-Q. The game is displayed on a 1.8-inch screen, where apples fall from the top of the screen and the user has to catch them using a basket. The movement of basket is controlled with a biaxial joystick.

Motivation

Ever since I was a kid, I’ve been passionate about playing games in my free time. When I started learning how to code, I wanted to start making my own game. However, building a modern and complex game requires a lot of time, resources and knowledge. So for this project, I decided to recreate a classic game from my childhood, with the help of hardware components, not only digitally.

Architecture

This project's architecture revolves around the STM32 Nucleo-U545RE-Q microcontroller.

  • STM32 Nucleo-U545RE-Q
  • Breadboard: allows easy connections among the components of the project
  • LCD SPI 128x160 Module: the screen where the game will be displayed.
  • Joystick breakout board: the joystick which will be used to move the basket to the left or to the right.
  • 3 Blue LEDs: the LEDs which will show the remaining lives of the player. They are all turned on when the game starts and one of them turns off when an apple falls on the ground.
  • 1 RGB LED: this LED will turn green when the player catches and apple, red when an apple falls on the ground and when the player loses the game, and yellow for a 3-seconds countdown before the game starts.
  • 2 Passive Buzzers: one of these buzzers will make a sound each time the player loses one life. The other buzzer will make different sounds when the game starts and when it ends.

hardware scheme

Log

Week 30 March - 5 April

I sent my project idea and received feedback.

Week 6 - 12 April

I ordered the components based on the feedback and picked them up.

Week 13 - 19 April

I did some initial testing to see if the components work.

Week 20 - 26 April

I continued the testing, wrote the page of the website and started writing the actual code of the project.

Week 27 April - 3 May

I had an issue where my screen would stay white, regardless of the commands written in code. I managed to fix it by using a different crate. Also, I found a way of drawing my objects by importing images modified on a website which created an array of pixels. I had to find a way to remove the white background of the pictures, which turned out to be different shades of white, so I couldn't just manually exclude those pixels.

Week 4 - 10 May

I had a problem where the buzzers were not working, but I fixed it. I finished the wiring, which will be slightly changed later on, and I finished the KiCAD schematic.

final wiring

Week 11 - 17 May

I worked more on my code and decided to make separate files for pins, display, leds and buzzers, which created a few problems with the pins initialization. I was able to solve them and had to change the initial implementations of my components as well.

Week 18 - 24 May

I had a problem with reading the joystick values and solved it using DMA.

Also, I needed to make the box used to carry the project look nicer and not have all the wires visible. This is why, I made some holes on the top part to have only the leds, display and joystick visible and left the buzzers on the breadboard. I covered the box in white sticker, which took two people and a lot of patience, then cut the holes again. After attaching the display and the joystick and wiring them, I realised that my wires are not long enough to connect the leds too from where they were initially on the breadboard. Here, I was faced with two choices: either order longer wires and pick them up the next day or move the led wires closer and the buzzers more to the side (they were in the middle). I spent the next hour rewiring them, only to then realise that my box would not close anymore. I was able to close it after a bit of struggle and then ran my code again to make sure that everything was working well and no wires were disconnected by mistake.

Week 25 - 29 May

During the final week, I only worked on the code and finalized the game logic, as well as the other game effects.

final box

Hardware

Schematic

KiCAD schematic

Bill of materials

DeviceUsagePrice
STM32 Nucleo-U545RE-QMain microcontrollerborrowed
BreadboardConnects the microcontroller to the components21.18 RON
LCD SPI 128x160 ModuleDisplays the game24.59 RON
Joystick breakout boardControls the movement of the basket5.35 RON
Blue LEDsShows the remaining lives of the player0.87 RON
RGB LEDShows visual cues1 RON
Passive BuzzersAudio cues2 RON
Male-Female Jumper WiresConnection of devices to breadboard and microcontroller8 RON
Male-Male Jumper WiresConnection of devices to breadboard and microcontroller12 RON

Software

Library/CrateDescriptionUsage in project
embassy-stm32Hardware abstraction layer for STM32Provides type-safe access to peripherals (SPI, GPIO, PWM, ADC, timers)
embassy-syncProvider of synchronization primitivesAllows tasks to communicate without blocking each other
embassy-futuresCollection of utilities for working with FuturesMakes sure the game does not freeze and keeps running
embassy-executorThe async runtimeRuns main game loop
embassy-timeEfficient for async embedded applicationsControls falling speed timing, delays and time durations
defmtEfficient embedded logging frameworkDebugs and tracks game changes
defmt-rttBackend for defmt to output logs via probe-rsUsed in all files
panic-probePanic handler that prints to defmtUsed in all files
embedded-graphics2D graphics library for no_std embedded devicesDraws the apples, basket and score text
embedded-halTraits for reading analog values and digital pinsReads joystick axis and converts raw ADC values to screen positions
mipidsiDisplay driver to connect to TFT displaysInitializes and controls my ST7735 display
heaplessStack allocated strings for no_stdUsed for displaying text on start and game over screens
  1. Rust Embassy Book
  2. Screen connection documentation - explains what each pin of the screen is used for and how to connect them.
  3. Joystick Datasheet
  4. Joystick Documentation - more information about the joystick
  5. KiCAD schematic pins documentation
  6. image2cpp - website where you can turn an image into an array of pixels