Frogger-G: An accelerometer game on MBED LPC1768
For the Mbed mini project, I developed a simple game that uses an ARM Microcontroller (LPC 1768), an accelerometer, a smart color LCD and a speaker. The technical specifications for the parts are mentioned in detail later.
The game is inspired by the popular arcade game ‘Frogger’. The frog follows the movement of the accelerometer and the goal of the game is to direct the frog to the other side of the street while avoiding the cars.
The code for the game was developed in C++ using the mbed cloud compiler. I have used the mbed’s Real Time Operating System (RTOS) to implement various threads that control the different components of the game. Mutex locks are used to access the shared resource (LCD) between the threads. The different thread functions are as follows:
- Thread 1 : Moves the red car. Runs update twice per second.
- Thread 2 : Moves the red car. Runs update 5 times per second.
- Thread 3 : Sound effect for the moving cars. Runs update twice per second.
- Thread 4 (main thread) : Checks the accelerometer readings to control the position of the frog.
Also detects collision between the cars and the frog and updates the status of the game (Game over or User wins).
Components and Technical specifications:
1. NXP LPC1678 microcontroller
2. ADXL345 accelerometer :
The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is accessed through an SPI bus Connections
|MBED pin||ADXL345 Signal Name|
3. uLCD-144-G2 128 by 128 Smart Color LCD Connections
|MBED pin||LCD Signal Name|
4. Analog Speaker:
Hooking up the speaker directly to an mbed output pin results in very low volume and a driver circuit is needed to boost the current levels to drive the speaker to provide adequate volume levels. Hence the power transistor is used Connections
The code can be imported from http://mbed.org/users/yhazrat3/code/frogger_G/
1 comment on Accelerometer Game:
Please log in to post comments.