Skip to content
All projects

Embedded systems · Spring 2026

STM32 Snake Game & Task Scheduler

A joystick-controlled Snake game that brings together STM32 firmware, an LED display, audio, and interrupt-driven task scheduling.

Inside the project

Developed the game firmware around joystick input, an 8×8 LED matrix, and piezo audio, with menu, gameplay, and sleep states. A linked list represents the snake as it grows.

Implemented a five-task round-robin scheduler for movement, loss detection, win detection, apple detection, and rendering. SysTick and PendSV support context switching with 1 ms time slices.

Debugged the interaction between scheduling and wait-for-interrupt sleep: both relied on SysTick, so their timing had to work together. Sleep behavior included periodic joystick checks.

Challenges & decisions

After finishing one game, the system could get stuck in sleep instead of returning to normal operation. Getting the game to run once was not enough; the transitions between gameplay, the menu, and sleep had to work too.

I reworked how the round-robin scheduler interacted with those states. When gameplay ends, the code resets the scheduler to a single task so the old game tasks are no longer selected, while SysTick keeps running for timing and periodic joystick checks.

A closer look

STM32 Snake game running on an 8 by 8 LED matrix with joystick control
Snake running on the LED matrix with joystick control.