Select Page

ABSTRACT

A multi-game embedded system was implemented on the TM4C123GXLmicrocontroller [1] using a 32×8 WS2812B addressable RGB LED grid. The system supports Snake, Tetris, and Space Invaders with joystick-based input, DFPlayer-based audio output, and EEPROM-based persistent high-score storage. The implementation focuses on timing-critical LED driving, fixed step frame scheduling, coordinate remapping, and reliable low level peripheral interfacing.

I.INTRODUCTION

This work presents the design and implementation of a compact retro gaming system using the TM4C123GXL microcontroller. A 32×8 WS2812B addressable RGB LED grid is used as the dis- play, driven through a single-wire timing-sensitive protocol. Three games —Snake, Tetris, and Space Invaders—are implemented with joystick-based control and audio feedback using a DFPlayer Mini module.

The system emphasizes precise timing control, deterministic frame-based execution, and efficient mapping between logical game coordinates and the physical LED arrangement. The project integrates multiple peripherals while maintaining real-time responsiveness within the constraints of a resource-limited embedded platform.

II.SYSTEM-LEVEL ARCHITECTURE

Fig. 1: System-level architecture

The TM4C123GXL acts as the central controller interfacing with input devices, LED display, audio module, and internal EEPROM. The system operates on a frame-based loop where input is polled, game logic is updated, and output is rendered to the LED grid.

The architecture separates input handling, game logic, rendering, and peripheral communication, allowing deterministic execution and modular integration of multiple games within a single firmware framework.

III.HARDWARE DESIGN

The hardware consists of the TM4C123GXL microcontroller, a WS2812B LED matrix, joystick inputs, DFPlayer Mini audio module, and onboard EEPROM. The LED grid is driven through a single GPIO line, while UART1 is used for audio communication. All peripherals are powered using a regulated 5V supply.

TABLE I: hardware components and interfaces

A.WS2812B Interface

Each WS2812B LED [2] receives 24-bit color data in GRB format using a single-wire protocol. Data transmission relies on precise pulse-width encoding, where logic ‘0’ and logic ‘1’ are differentiated by hIGh pulse duration. After all data is transmitted, a LOW signal exceeding 50 µs latches the frame.

256 × 24 = 6144 bits/frame

Due to strict timing requirements, the signal is generated using GPIO bit-banging with interrupts disabled during transmission to prevent timing violations.

IV.SOFTWARE DESIGN

The firmware follows a fixed-step frame scheduler operating at 60 FPS. Each frame performs input polling, game-state updates, rendering, and LED refresh. Independent tick counters are used to decouple gameplay updates from rendering rate.

Fig. 2: WS2812B timing and data transfer

A. Frame Scheduler

The system operates at:

FPS = 60  Tframe ≈ 16.67ms

A delay loop enforces frame timing:

Game logic updates are controlled using tick counters:

For example:

60/5  = 12 ⇒ movement every 12 frames.

This ensures smooth rendering while maintaining controlled game- play speed.

B. Logical to Physical Mapping

The game logic operates on an 8×32 coordinate system, while the physical LED grid is arranged as 32 × 8. A coordinate transformation is applied:

xp = 31 − yl,     yp = xl

Additionally, serpentine LED wiring is corrected in software, enabling flexible hardware layout without affecting gameplay logic.

V.EEPROM HANDLING

high scores are stored for each game and difficulty level using a structured mapping:

address = ((game Mode × 4) + difficulty) × 4

3 × 4 = 12 entries

high Scores [3] [4]

Each entry occupies 4 bytes. EEPROM initialization is verified using:

0xFFFFFFFF

If detected, all entries are reset to zero. This ensures persistent and reliable score storage across power cycles.

VI.AUDIO HANDLING

The DFPlayer Mini [3] is controlled using UART1 with a fixed 9600 baud rate. Communication is performed using structured command frames:

7E FF 06 CMD 00 Dh DL ChK_h ChK_L EF

The checksum is computed as:

ChK = −(FF + 06 + CMD + DATA)

Raw UART register configuration with the internal 16 Mhz PIOSC clock is used to ensure stable timing independent of system PLL configuration.

Audio playback is event-driven and triggered by gameplay events:

  • Snake: food collection sound
  • Tetris: background music
  • Space Invaders: enemy-hit sound
  • Game over: termination sound

Tetris playback uses a separate audio path because DFPlayer loop-state behavior can persist into later tracks. The firmware resets playback state when leaving Tetris to prevent loop-mode effects from affecting other sound events.

VII.GAME IMPLEMENTATION

Each game is implemented using a common framework consisting of:

  • frame-based scheduling,
  • tick-driven updates,
  • collision detection,
  • rendering to LED

A. Snake

Snake maintains arrays for body coordinates, current direction, food position, and length. On each movement tick, body segments are shifted, the head is advanced, and collision checks are performed. Food collection increases length, updates speed, and triggers audio playback.

B.Tetris

Tetris uses a 32 × 8 board and 16-bit encoded tetromino patterns. Each piece is updated using joystick input for horizontal movement, rotation, and soft drop. Gravity ticks move the piece downward; once collision occurs, the piece is locked, full rows are cleared, score is updated, and a new piece is spawned.

VIII.LIMITATIONS AND FUTURE WORK

The current WS2812B refresh blocks interrupts during frame transmission, which limits concurrent interrupt-driven processing. Space Invaders uses integer-grid movement, restricting fine-grained motion. DFPlayer loop control also required additional state handling to avoid persistent loop behavior.

Future improvements include DMA/SPI-based LED driving, im- proved audio state management, additional games, configurable brightness profiles, and support for higher-resolution LED matrices.

IX.CONCLUSION

A multi-game embedded console was successfully implemented on the TM4C123GXL platform. The project integrates timing-critical LED control, frame-based game scheduling, joystick input, UART audio playback, and EEPROM persistence. The implementation demonstrates complete embedded system integration using both software architecture and low-level hardware interfacing.

REFERENCES

[1] Texas Instruments, “Tiva tm4c123gh6pm microcontroller datasheet,” https://www.ti.com/lit/ds/symlink/tm4c123gh6pm.pdf, 2014, 80 MHz ARM Cortex-M4F MCU with integrated EEPROM and multiple UART interfaces.
[2] WorldSemi, “Ws2812b intelligent rgb led datasheet,” https://www.alldatasheet.com/datasheet-pdf/pdf/1179113/WORLDSEMI/ WS2812B.html, single-wire protocol, 24-bit GRB data, precise pulse timing.
[3] DFRobot, “Dfplayer mini mp3 module datasheet,” https://dfimg.dfrobot. com/wiki/20532/DFR0299 mp3-player-module datasheet V1.0.pdf, uART-controlled MP3 decoder with FAT16/32 support and serial command interface.