John Graeme Dockrill | Mechatronics Engineering

6th Year Student at UBC | graeme.dockrill01@gmail.com

Highway Racer Game

September 2023


Project Overview

Developed Skills

  1. Programmed an MSP430FR5739 microcontroller in C to read IMU data and send it over UART to PC
  2. Created a windows-forms-based game to accept serial data from MCU and use the bytes as user input
  3. Use user input to control a car in the game that has to avoid the other cars, and tracks highscore
  • Embedded Design
  • MCU Datasheet
  • C# Programming
  • UART Protocol

Objective

This project was assigned as part of my class MECH 423, where we were tasked with making something creative using windows forms and the MSP430FR5739 MCU.


MSP430FR5739 Board

The Board

To start with this project I knew I wanted to do some sort of scrolling game where the player controls a car and has to avoid obstacles.

First, I had to figure out what peripherals the MSP430 board has available. Which was done using the Family User Guide and looking at the circuit diagram of the board (shown below).

Then I needed to figure out how to transmit the serial data back to the computer using the UART peripheral.

The MSP430 firmware code is shown below. I wrote custom functions for setting up the perpherals and for sending data.


MSP430 circuit diagram

MSP430 firmware code

The Windows Form

Next, I needed to figure out how to accept serial data in windows forms and how to parse the incoming data bytes for the user input.

This was done by using a serial control in windows forms and setting the baud rate equal to what it was set on the MSP430 board itself.

I found some assets online and modified them for match what I wanted.

Snippet of winforms code


Player car sprite

Enemy car sprite

Enemy car sprite

Playing Highway Racer

Completed Game

After the game was completed, all that was left was to have some fun!

A gif of me playing Highway Racer can be seen on the left.

The game is extremely fun and I got lost playing it for an hour or so.


Final Remarks

This project was extremely fun to complete, as I learned a lot about low-level firmware for microcontrolelrs, and how to read datasheets to accomplish what I need.

I also learned a lot about windows forms and data transmission between a microcontroller and your PC.