← Back to projects

Embedded Mini Golf Game

Tilt-controlled mini golf game with SPI LCD graphics and MPU-6050 motion input, randomized holes via RNG, and millisecond timing with SysTick.

STM32SPII2CRNGSysTickMPU-6050

Highlights

  • LCD rendering + game loop + collision / hole detection
  • MPU-6050 pitch/roll for control; low-level I2C driver
  • CMSIS Register-level peripherals (SPI, UART, RNG, SysTick)

This project is a fully integrated embedded mini golf game on an STM32L432KC. The game renders graphics on a 240×280 SPI LCD, reads motion input from an MPU-6050 over I2C, and uses the MCU’s RNG peripheral to randomize hole/ball placement each round. Timing is driven by SysTick interrupts to support millisecond-scale delays and smooth gameplay.

The software is organized into clear peripheral drivers and a game logic layer, with a state-machine structure documented in the repo.

Features
- Tilt-controlled gameplay using MPU-6050 motion input (pitch/roll)
- SPI LCD graphics: title screen, ball animation, hole detection, score screen
- Randomized ball/hole positions using the STM32 hardware RNG
- SysTick-based timing for precise delays and time tracking
- Multiple low-level protocols in one system: SPI, I2C, UART, SysTick

Hardware Used
- STM32L432KC (CMSIS framework)
- MPU-6050 gyroscope/accelerometer
- 1.69" 240×280 SPI LCD
- External buttons for start/reset

Software Structure
- main.c: hardware initialization + top-level flow
- game.c/h: game logic, motion handling, collision/hole detection
- lcd.c/h: LCD control + rendering pipeline (SPI)
- gyro.c/h: computes pitch/roll from MPU-6050 data
- i2c.c: low-level I2C driver for the MPU-6050
- spi.c/h: low-level SPI driver for the LCD
- rng.c/h: hardware RNG init + random placement
- systick.c/h: SysTick config + millisecond delays

Design Artifacts
- Includes a system block diagram and a state machine diagram in the README for overall architecture and control flow.