Pong Game with Photoresistors
.
Overview
This project consists of the game of Pong being displayed to a uLCD, with paddles being controlled by photocell resistors. The game starts at the sound of a buzzer. The Ball bounces on the horizontal walls, and the aim of the game is to stop the ball from hitting the vertical borders. In order to do that, the paddles, which are controlled by photocell resistors can be moved vertically. To go upwards, increase the light on the photocell resistors and to move down, reduce the light being taken in to the photocell resistors. A buzzer sounds at the beginning and at the end of the game, and a thread allows a small sound to be made when the ball collides on the borders.
This is a picture of the wiring for the game.
Figure 1. Wiring of Game
Setup
The components that were used (as can be seen in figure 1) were
- 1 mbed
- 1 uLCD
- 1 Speaker
- 1 Op Amp
- 1 220-1k Resistor
- 1 SD Card Reader
- 2 Photocell Resistors
- 2 10 Ohm Resistors
Circuit
Below we have some diagrams of the pinouts of the components above.
SD Card
SparkFun MicroSD Breakout Board
uLCD
Speaker
The Speaker uses pin 18.
Photocell resistors
The photocell Resistor for the left paddle uses pin 15. The photocell Resistor for the right paddle uses pin 16.
Gameplay
Source Code
The Code uses the following libraries
- mbed.h
- uLCD_4DGL.h
- SDFileSystem.h
- wave_player.h
- <string>
- rtos.h
The code is the following
Import programECE-4180Lab4
Code for The game of Pong using Photocell Resistors
Please log in to post comments.