Voice Controlled Dino Game

Summary of Voice Controlled Dino Game


This project develops a voice-controlled Dino game using a PIC32 microcontroller and TFT screen. Players jump over cacti using a button or by whistling, avoiding internet dependency. The system employs ADC for audio sampling, FFT with Hann windowing for frequency detection, and optimized bitmap rendering to maintain 30 fps. It features a Python GUI, score tracking, and sound effects via DMA.

Parts used in the Voice Controlled Dino Game:

  • PIC32MX250F128B microcontroller
  • SECABB development board
  • TFT LCD display (320x240 color)
  • Analog to Digital Converter (ADC) module
  • Digital to Analog Converter (DAC)
  • Microphone
  • Audio jack
  • Serial debugger
  • Python GUI software
  • Remote desktop computer

Introduction

We have all been in a situation where we didn’t have access to the internet and to pass time we started playing the Google Dino game. However, the game tends to get a little monotonous with all the key presses and the biggest fear is that if we regain the internet connection, we might lose the progress, especially if we are about to beat a high score. Therefore, for our final project, we wanted to create our own version of the Dino game using the PIC32 microcontroller and the TFT screen which can be controlled with our voice. That way, we could play the game any time we wanted without the fear of losing progress by regaining the internet connection.

High Level Design

The game begins with a start screen with very minimal text saying Press Start!. Once the start button is pressed, the screen updates and the game starts. The game is fairly straightforward with a dino player running. The main task of the game is to keep jumping over obstacles (cactii) and not die. As long as the player is alive, the game keeps on running and generating newer obstacles.

In order to control the dino, the user can use the Jump button which updates the y-velocity of the dino and makes it jump. Once the dino has jumped, the gravity acts on it and its velocity changes each frame. Once the diono hits the ground again, the velocity is reset to 0. Whistling into the microphone can also make the dino jump. Once the dino passes an obstacle, the score is incremented.

If the player fails to make the dino jump and it hits an obstacle, the dino dies and the game over screen is displayed along with the score and high score. In order to start the game again, the user needs to press the Restart button on the GUI.

The basic flow diagram of the system is shown below. Note: There is an additional ISR which is not a part of the flow diagram but is a part of the main program.

The Flowchart of the Game

Quick Solutions to Questions related to Voice Controlled Dino Game:

  • How is the dino controlled?
    The user can press the Jump button on the GUI or whistle into the microphone to make the dino jump.
  • What algorithm detects the whistle sound?
    The system uses the Fast Fourier Transform (FFT) combined with a Hann window to analyze audio frequencies.
  • Why was fixed-point arithmetic used?
    Fixed-point arithmetic was used because floating-point calculations are CPU intensive and slow, which would hinder the frame rate.
  • What is the target frame rate of the game?
    The game is designed to run at 30 frames per second to ensure an aesthetically pleasing experience.
  • How does the system filter out DC noise from the audio input?
    A basic RC high pass filter consisting of a 1uF capacitor and a 10k resistor is connected at the ADC input.
  • What range of frequencies triggers the jump action?
    The dino jumps when the detected frequency falls between 1500Hz and 1800Hz.
  • How are sound effects generated?
    Sound effects like jumping and dying are played using Direct Memory Access (DMA) to send pre-converted audio arrays to the DAC.
  • What optimization was made for drawing bitmaps?
    The team created a custom drawBitmap function that sets the address window once instead of configuring it for every pixel.
  • How is the game restarted after the player dies?
    The user must press the Restart button on the GUI to reset the game state and scores.

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.