EVERYONE LOVES GAMES!
In this project, I built a video game controlled by people’s voice. The game is about jet fighters. People can play the game by themselves or with friends. The system recognize the command by distinguish “ahh” and “Biu”. The fighters shoot a bullet when the players say Biu and rise when people say ahh. If players keep silent, the fighters will be falling. The AT Mega1284 was used as the processor for voice recognition and video output, two 3.5mm phone ports were set for microphones and another 3.5mm port was introduced for NTSC output.
High Level Design
The whole project can be divided into three parts: the voice receiving and recognizing part, the game execution part and video output part. There are two microphones for voice input, and an external circuit to filter and amplify the signal for MCU to recognize. For each microphone, there’s an ADC channel to read the value. In that way, I can get the voice input signal in MCU. After that, a method is required to distinguish between ahh, biu and nothing. When the input commands are recognized, the MCU need to compute the game. For example, what’s the location of the fighters, are they hit by bullets or obstacles, what else will be generated etc. At last, the MCU should draw on a screen buffer and output that for a LCD screen in NTSC system.
In the voice recognition part, I’m interested in voices’ fundamental frequency. Usually the fundamental frequency of people when they’re speaking is about 50-350Hz, so I can concentrate on this range. I filtered the voice using a band-pass filter so I can filter the DC signal and the high-frequency harmonic wave that I don’t need. Also, since the signal that microphone generated is too small for MCU to read accurately, I used an opamp to amplify that. In this way, I can use a simple zero-crossing method to calculate the fundamental frequency of a voice, because the amplitude of the waveform is high and the noise is low.
In the game, the fighters are near the edge of the screen and they can only rise or fall in one demensional way controlled by the voice ahh. When the players say biu, it shoot a bullet to the other side of the screen.
There are two game modes: single mode and VS mode. In single mode, the player controls the fighter to avoid or shoot the obstacles that are coming randomly from the right edge of the screen. Once the obstacle hit the plane, the game will be over and the score is how many obstacles the player has shot. This game mode is really simple but classic, it’s easy to start with.
In VS mode, the game is more complicated. There is no obstacle and two players are set on each side of the screen. The players shoot to each other and try to avoid bullets from the opponent. To increase the fun of the game, there are several buffs that can improve or reduce the fighters’ ability. The buff can increase/decrease the size of the bullet, accelerate/decelerate the speed of the bullet, give extra HP or multiple bullets etc. The buffs appear in the middle of the screen and randomly move to left or right. In this mode, every player has 16 HP initially, and the HP decreases by the size of the bullet. When either player’s HP becomes 0, the game is over.
For video output part, I used the part of the code from lab3 of ECE 4760 where the resolution is 160*200. After the calculation of game playing, the MCU draws everything on the screen buffer and pop that out to the LCD. I used NTSC system in the project.
Low Level Design
Hardware Circuit Design
To implement the microphones, I designed a circuit as figure 1. C1 and R2, R3 works as a high pass filter whose cut off frequency is about 32 Hz. Also, R2 and R3 provide a 2.5V DC offset for the output to allow a larger waveform amplitude. However, the amplitude of the output is really small that I need to amplify that for accuracy. Also, the components of the human voice are complicated because of the harmonic waves, so I need to use a filter.
The amplification factor is about 50, and the band is between 16Hz and 312Hz. After the filtering, we can get a much nicer waveform for MCU to recognize. I used LM358 for opamp and it has two amplifiers on one chip, which is perfect because I have two microphones. Figure 3 gives a picture of the part of the board of audio inputs. The final outputs are connected to port A0 and A1 of the MCU for ADC.
|Item Name||Unit Cost||Quantity||Total Cost|
|3.5mm Phone Plug||3|
|R & C & Wire||Several|
For more detail: Ahhhh…BIU! video game Using Atmega1284