Accelerometer Game

Frogger-G: An accelerometer game on MBED LPC1768


Overview

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.

/media/uploads/yhazrat3/setup.png

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.

/media/uploads/yhazrat3/screenshots.png

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).

Demo


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 pinADXL345 Signal Name
VoutVcc
GndGnd
SDAp5
SDOp6
SCLp7
CSp8

3. uLCD-144-G2 128 by 128 Smart Color LCD Connections

MBED pinLCD Signal Name
VU5V
GndGnd
TXRX
RXTX
p11Reset

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
/media/uploads/yhazrat3/speaker.png


Program

The code can be imported from http://mbed.org/users/yhazrat3/code/frogger_G/

References



1 comment on Accelerometer Game:

01 Aug 2019

please give the circuit diagram for this project.

Please log in to post comments.