Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2eac6d6
Create index.md
Asmd-44 Apr 26, 2026
030ba3b
Delete andra_sara.duminica/index.md
Asmd-44 Apr 26, 2026
5a1cf99
Create index.md
Asmd-44 Apr 26, 2026
58d5813
Add files via upload
Asmd-44 Apr 26, 2026
894d040
Update index.md
Asmd-44 Apr 26, 2026
da43bfd
Update index.md
Asmd-44 Apr 26, 2026
a32622e
Update website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 Apr 26, 2026
010310d
Merge branch 'main' into main
Asmd-44 Apr 26, 2026
8e0659e
Merge branch 'main' into main
Asmd-44 Apr 28, 2026
45cdc3b
Merge branch 'main' into main
victorlisman Apr 30, 2026
a92dc6a
Add files via upload
Asmd-44 May 10, 2026
f68f50d
Update index.md
Asmd-44 May 10, 2026
f50114e
Update index.md
Asmd-44 May 10, 2026
40747e0
Merge branch 'main' into main
Asmd-44 May 10, 2026
289943a
Delete website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 May 10, 2026
d76a23b
Add files via upload
Asmd-44 May 10, 2026
9dcdcd6
Update index.md
Asmd-44 May 10, 2026
4822cb2
Delete website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 May 10, 2026
5bba6b3
Add files via upload
Asmd-44 May 10, 2026
a840911
Update index.md
Asmd-44 May 26, 2026
280ef9b
Delete website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 May 26, 2026
e87e0c7
Add files via upload
Asmd-44 May 26, 2026
240d507
Update index.md
Asmd-44 May 26, 2026
7f9b111
Delete website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 May 26, 2026
b26e69e
Add files via upload
Asmd-44 May 26, 2026
56857f0
Update index.md
Asmd-44 May 26, 2026
c6e3dc1
Delete website/versioned_docs/version-fils_en/project/2026/andra_sara…
Asmd-44 May 26, 2026
8f2a74e
Add files via upload
Asmd-44 May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,78 @@ A real-time embedded rhythm game where the user must press buttons in sync with

## Description

This project implements a real-time embedded rhythm game using an STM32 microcontroller. The system extends a simple music box into an interactive game where the user must follow the rhythm of a melody.
This project implements a real-time embedded rhythm and memory game using an STM32 microcontroller.

The device plays an 8-bit melody using a buzzer while LEDs light up in a predefined sequence corresponding to the rhythm. Each LED is mapped to a specific button, and the user must press the correct button at the correct time.
The gameplay is based on two different modes:
-**Rhythm Mode**: the device plays melodies using a passive buzzer while LEDs light up in predefined sequences corresponding to the rhythm. Each LED is mapped to a specific button, and the player must press the correct button at the correct time.
-**Memory Mode**: the player must memorize and reproduce LED sequences of increasing complexity.

The system evaluates the user’s input in real time, checking both correctness and timing accuracy. Based on performance, a scoring system calculates metrics such as correct hits, missed inputs, and overall accuracy. At the end of the song, the final score is displayed on an OLED screen.
The game evaluates both timing accuracy and input correctness. Correctly timed inputs increase the score, while missed or incorrect presses reduce the player’s performance. In Memory Mode, the score depends on how accurately the user reproduces the generated LED patterns and stops at the first wrong hit. The system also stores separate high scores for different game modes and difficulty levels.

The system uses **three interchangeable cartridges**, each corresponding to a different melody, allowing easy switching between songs and future extensibility.
The game includes multiple songs and difficulty levels selectable directly from the OLED menu interface. The system also uses two SG90 servo motors to provide physical animated feedback during boot and when the player achieves a new high score, making the experience more dynamic and interactive.

---

## Motivation

The motivation behind this project is to explore real-time embedded systems through an interactive and engaging application. It combines hardware control, precise timing, and user interaction, making it a practical way to understand synchronization, input processing, and modular system design.
I chose this theme for my project because I'm interested in both music and visual design and wanted to combine them into an interactive embedded system. I am especially passionate about the aesthetics and digital culture of the 2000s era, including its nostalgic visual style and retro electronic sound. This project allowed me to combine those artistic influences with real-time embedded programming, hardware interaction, and game design.

---

## Architecture

The system is structured as a set of interacting modules:

- **Main Controller** – coordinates the entire system
- **Cartridge Decoder** – detects which of the three cartridges is inserted
- **Melody Manager** – handles song playback and timing
- **LED Controller** – generates visual rhythm cues
- **Button Handler** – reads and debounces user input
- **Rhythm Checker** – verifies timing accuracy of button presses
- **Score System** – computes performance metrics
- **Buzzer Controller** – generates audio output
- **OLED Controller** – displays feedback and final results
- **Main Controller** – coordinates the entire system and manages game flow
- **Menu System** – handles navigation between game modes, songs, and difficulty levels
- **Melody Manager** – handles song playback and rhythm timing
- **LED Controller** – generates visual gameplay and feedback effects
- **Button Handler** – reads and debounces user input
- **Rhythm Checker** – verifies timing accuracy of button presses in Rhythm Mode
- **Memory Engine** – generates and validates LED memory sequences
- **Score System** – computes scores, penalties, and high scores
- **Buzzer Controller** – generates audio output and sound effects
- **OLED Controller** – displays menus, scores, and gameplay feedback
- **Servo Controller** – controls animated physical feedback during boot and high-score events

The modules communicate through the microcontroller, which acts as the central unit coordinating all operations.

![System Diagram](FINAL_DIAG.drawio.svg)

---

## Journal
## Log

### Week 5 – 11 May


- Defined the project idea and overall architecture
- Chose the hardware components
- Tested LEDs and push buttons on STM32
- Tested OLED display communication over I2C
- Implemented melody playback using PWM and passive buzzer
- Implemented rhythm gameplay logic

![Hardware Prototype](hardware_photo_f.webp)

### Week 12 – 18 May


### Week 19 – 25 May
- Implemented the OLED menu system
- Added multiple songs and difficulty selection
- Implemented score calculation and gameplay feedback
- Added Memory Mode gameplay logic
- Improved button handling and timing accuracy
- Added high-score tracking system
- Integrated OLED feedback screens and score display

### Week 19 – 25 May

- Added SG90 servo motor support
- Implemented boot and high-score animations
- Redesigned GPIO pin mapping and button layout
- Improved gameplay stability and timing synchronization
- Finalized hardware integration and debugging
- Built the case for the components

---

## Hardware
Expand All @@ -66,31 +93,55 @@ The system uses the following hardware components:

- STM32 Nucleo board
- Passive buzzer
- LEDs (multiple colors)
- Push buttons (3–4)
- 6 LEDs (5 gameplay LEDs + 1 status LED)
- 5 Push buttons
- SSD1306 OLED display (I2C)
- Breadboard and jumper wires
- Header pins for cartridge system
- Breadboard and jumper wires
- 2 SG90 servo motors
- MB102 breadboard power supply module
- Header pins for cartridge system
- Resistors

---

## Schematics

![System Diagram](final_fiag.svg)

![Hardware Schematic](music_box_rhythm_game.svg)

---

## Bill of Materials (Estimated Cost)

- STM32 Nucleo board – ~120–180 RON
- Passive buzzer – ~5–15 RON
- LEDs – ~10–20 RON
- Resistors – ~5–10 RON
- Push buttons – ~10–20 RON
- SSD1306 OLED display – ~30–60 RON
- Breadboard – ~15–30 RON
- Jumper wires – ~10–20 RON
- Header pins (cartridge system) – ~5–10 RON

**Total estimated cost: ~200–350 RON**
- 1x Passive buzzer – 1 RON
- LEDs and Resistors set – 23 RON
- 5x Push buttons – 10 RON
- 1x I2C OLED display – 22 RON
- 3x Breadboards – 30 RON
- Jumper wires – 25 RON
- 2x SG90 servo motors - 23 RON
- 1x MB102 breadboard power supply module - 4 RON
- Case building materials- 60 RON

**Total cost: 198 RON**

---

## Software

| Library | Usage |
|----------|--------|
| embassy-stm32 | STM32 peripheral access and GPIO control |
| embedded-hal | Hardware abstraction layer |
| ssd1306 | OLED display driver |
| embedded-graphics | OLED text rendering |
| cortex-m | Low-level ARM Cortex-M support |
| cortex-m-rt | Runtime and startup code |
| panic-halt | Panic handling for embedded systems |

---

## Links




Loading