Racing car project with LCD and Joystick
Introduction
In this project we created a racing car game with an analog joystick input to control the car's speed and direction. The SD card reader is used to store the sound file of the project which is output by the Class D speaker. The uLCD is used to display the game and the SD card slot behind the uLCD is used to store the picture of the loading and fail screen. As the game start, the car is travel at a speed which could be controlled by the user. The user will win the game by travel a certain distance and dodge some randomly generated obstacle. If the car hit any obstacle the game will display the losing screen.
Components used:
-Thumb Joystick
-SD Card Reader
-Class D Amplifier
-Speaker
-uLCD
We created a racing car game with the LCD display, Class D Speaker, SD card reader, and thumb joystick.
Thumb Joystick
Joystick | mbed |
---|---|
VCC | p 40 - Vout |
VERT | p 15 |
HORZ | p 16 |
SEL | not using |
GND | p 1 - GND |
SD Card Reader
The following table is the pin diagram for the SD card Reader
MicroSD Breakout | Mbed |
---|---|
CS | 8 (DigitalOut cs) |
DI | 5 (SPI mosi) |
VCC | VOUT |
SCK | 7 (SPI sclk) |
GND | GND |
DO | 6 (SPI miso) |
CD | Not connect |
For more reference please visit this page:
https://developer.mbed.org/cookbook/SD-Card-File-System
Class D Speaker
Following is the pin diagram for the Class D Speaker
mbed | TPA2005D1 | Speaker |
---|---|---|
gnd | pwr - (gnd), in - | |
Vout (3.3V) or 5V | pwr + | |
p26 (any PWM or D/A) | in + | |
out + | + | |
out - | - | |
Any DigitalOut px(optional) | S (low for shutdown) |
For more reference please visit this page:
https://developer.mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/
uLCD
Following is the pin diagram for the uLCD display:
mbed | uLCD Header | uLCD cable |
---|---|---|
5V=VU | 5V | 5Vv |
Gnd | Gnd | Gnd |
TX=P13 | RX | TX |
RX=P14 | TX | RX |
P11 | Reset | Reset |
For more references of the LCD please visit this page:
https://developer.mbed.org/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/
Code for the Racing Car Project
Import programECE4180Lab4
ECE 4180 Lab 4 Racing Game
Video Demo
In this video, we ran the project showing both the victory and defeat conditions.
Please log in to post comments.