Project 02- Snake game for STM32F429-Discovery board

After first FFT project, I’ve decided to make a simple snake game. Basically I’ve made it in Labview first for my partial exam at the university. It looked great so why not port it also to STM32F429-Discovery board which has everything already prepared for us.

You just need USB OTG cable and external keyboard to drive snake and you are ready to play.

Snake game


  • Works on STM32F429-Discovery board
  • Supports external keyboard using USB HID Host stack on STM32
  • Supports selecting different speeds
    • More speed, more points
  • Standard snake game mode
    • Your goal is to make snake larger as possible
  • Supports 2 game modes
    • Mode 0: If you hit wall, game is stopped
    • Mode 1: If you hit wall, snake will come out at the other side of game area
  • Supports pause mode

Keyboard buttons and actions

Keyboard style for this project is QWERTY. If you put keyboard correct to USB, then GREEN led will be on, to detect this.

To operate with snake game, you will need buttons below:

  • All characters are LOWERCASE
  • w‘, ‘s‘, ‘a‘, ‘d‘: move snake to direction you want
  • r‘: resets game and starts again
  • m‘: toggles game mode between Mode 0 and Mode 1
  • u‘,’i‘: changes snake speed
  • p‘: toggles pause mode

When gameover occurs to you for some reason, you can press ‘r‘ (reset) key to reset it.

Source code

Entire project and source codes are in the bottom download. If you have any problems with compile (you shouldn’t have), there is also Snake.hex file included in project.

Tell me your best result in comments 😉


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...