Skip to content
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ If the complete sequence is entered correctly, the score increases by one and th
The maximum level is 20. If the player successfully completes all 20 levels, the OLED displays "YOU WIN" together with the final score.

After the game ends, the score remains visible for two seconds and the system automatically returns to the idle state, ready for another game.

---

## Motivation
Expand All @@ -44,38 +45,40 @@ The STM32 microcontroller acts as the central controller of the system.

The project consists of the following main components:

STM32U545RETxQ – controls the game logic and all peripherals
START Button – starts a new game
Color Buttons – allow the player to reproduce the displayed sequence
LEDs – display the generated color sequence and provide visual feedback
Passive Buzzer – generates a different tone for each color and additional game feedback sounds
OLED Display – displays the idle message, final score, and win message
- **STM32U545RETxQ** – controls the game logic and all peripherals
- **START Button** – starts a new game
- **Color Buttons** – allow the player to reproduce the displayed sequence
- **LEDs** – display the generated color sequence and provide visual feedback
- **Passive Buzzer** – generates a different tone for each color and additional game feedback sounds
- **OLED Display** – displays the idle message, final score, and win message

The five buttons are connected to GPIO inputs configured with internal pull-up resistors.

The four LEDs and the passive buzzer are controlled through GPIO outputs.

The OLED display communicates with the STM32 using the I2C protocol.

![System Architecture](project_diag.jpg)

---

## Log

### Week 1

* Defined the main idea and rules of the Memory Game
* Selected the required hardware components and assigned the STM32 GPIO pins
* Connected and tested the four LEDs and their corresponding push buttons
* Added the START button and implemented the idle state
* Implemented the random sequence generation and stored the sequence for each level
* Added the main game logic for displaying and checking the player sequence
* Connected the passive buzzer and added different tones for each color
* Connected the OLED display using I2C
* Added the `PRESS START`, score, and `YOU WIN` screens
* Added the LED animation while waiting for the game to start
* Tested the complete game and fixed button debounce and game-over behavior
* Added the automatic return to the idle state after the final score is displayed
* Finalized the hardware connections and tested the complete system
- Defined the main idea and rules of the Memory Game
- Selected the required hardware components and assigned the STM32 GPIO pins
- Connected and tested the four LEDs and their corresponding push buttons
- Added the START button and implemented the idle state
- Implemented the random sequence generation and stored the sequence for each level
- Added the main game logic for displaying and checking the player sequence
- Connected the passive buzzer and added different tones for each color
- Connected the OLED display using I2C
- Added the `PRESS START`, score, and `YOU WIN` screens
- Added the LED animation while waiting for the game to start
- Tested the complete game and fixed button debounce and game-over behavior
- Added the automatic return to the idle state after the final score is displayed
- Finalized the hardware connections and tested the complete system

---

Expand All @@ -92,41 +95,36 @@ The system uses the following hardware components:
- Breadboard
- Jumper wires

![Hardware Prototype](project.jpeg)

---

## Schematics

![Hardware Schematic](music_box_rhythm_game.svg)
![Hardware Schematic](project_sch.svg)

---

## Bill of Materials (Estimated Cost)

- 1x Passive buzzer – 1 RON
- LEDs and Resistors set – 23 RON
- 5x Push buttons – 10 RON
- 1x I2C OLED display – 22 RON
- 3x Breadboards30 RON
- Jumper wires – 25 RON
- 1x Passive buzzer – 1 RON
- LEDs and resistors set – 23 RON
- 5x Push buttons – 10 RON
- 1x I2C OLED display – 22 RON
- 2x Breadboard20 RON
- Jumper wires – 25 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 |
| embassy-stm32 | STM32 peripheral access, GPIO and I2C control |
| embassy-executor | Asynchronous program execution |
| embassy-time | Timers and delays |
| embedded-hal | I2C hardware abstraction |
| panic-probe | Panic handling |
| defmt-rtt | Debug transport required by the embedded environment |

---

## Links