Mbed Dance Dance Revolution
4180 Final Project
2016 Spring Semester Section B
Group members: Akshay Nagendra, Weiyu Liu
Overview
The goal of this project is to implement Dance Dance Revolution, a music snchronized video game, on the mbed platform. Dance Dance Revolution is a popular video game in which players stand on a "dance platform" or stage and hit colored arrows laid out in a cross with their feet to musical and visual cues. Players are judged by how well they time their dance to the patterns presented to them.
Design
Two mbeds are used in this design. The main mbed is responsible for running the game on two uLCD screens and taking players' inputs from two joysticks. The secondary mbed is responsible for playing the music. Two mbeds are communicating simple digtal signals with two wires.
Picture
Components
- Two mbeds
- Two uLCD-144 boards from 4D Systems
https://developer.mbed.org/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/ - Two Sparkfun's 5-way Tactile Navigation Switch Breakout Boards
https://developer.mbed.org/users/4180_1/notebook/using-a-navigation-switch-digital-joystick/ - Two SparkFun MicroSD Breakout Boards
https://developer.mbed.org/cookbook/SD-Card-File-System - One Sparkfun PCB or breadboard mount Speaker 8ohm .1W
https://developer.mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ - One Sparkfun Class D Audio Amp Breakout Board
https://developer.mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ - External Power Supply
Pin Connections
Main mbed
mbed LPC1768 | uLCD No.1 cable |
5V | 5V |
GND | GND |
TX = P9 | TX |
RX = P10 | RX |
P16 | Reset |
mbed LPC1768 | uLCD No.2 cable |
5V | 5V |
GND | GND |
TX = P28 | TX |
RX = P27 | RX |
P29 | Reset |
mbed LPC1768 | Sparkfun Nav Switch Breakout No.1 |
GND | - |
P12 | U |
P11 | C |
P13 | L |
P14 | D |
P15 | R |
nc - using internal pullups | + |
mbed LPC1768 | Sparkfun Nav Switch Breakout No.2 |
GND | - |
P23 | U |
P22 | C |
P24 | L |
P25 | D |
P21 | R |
nc - using internal pullups | + |
mbed LPC1768 | Micro SD Breakout No.1 |
P8 | CS |
P5 | DI |
Vout | VCC |
P7 | SCK |
GND | GND |
P6 | DO |
\ | CD |
Secondary mbed
mbed LPC1768 | Micro SD Breakout No.2 |
P8 | CS |
P5 | DI |
Vout | VCC |
P7 | SCK |
GND | GND |
P6 | DO |
\ | CD |
mbed LPC1768 | TPA2005D1 | Speaker |
GND | PWR-, IN- | |
External Power Supply | PWR+ | |
P18 | IN+ | |
OUT+ | + | |
OUT- | - | |
DO |
Connection between two mbeds
main mbed LPC1768 | secondary mbed LPC1768 |
songSelected P19 | P21 |
specificSong P20 | P22 |
Codes
Program for main mbed
Import programDanceDanceRevolutionMbed1
Dance Dance Revolution program for main mbed
Program for secondary mbed
Import programDanceDanceRevolutionMbed2
Dance Dance Revolution program for secondary mbed
Demo
Discussion
Main Section of Design
The main challenge of the game development is to synchronize multiple threads. The solution is to operate the mbed devices as RTOS devices. Parallel tasks are implemented as threads. Mutex locks are used for serial communications and other shared global resources. The audio synchronization entailed creating an arrow sequence that not only matched the tempo of the music being played, but also reflected the rhythms and notes of the song (e.g. if a particular note was played repetitively, the same arrow would appear on the screens)
Design Features
- joystick.h
In order to handle the user inputs in real time and never miss any inputs, we created an interrupt-driven joystick library to process user inputs. - Arrow.h
The arrow header file contains the class for a singular arrow on the screen, including its type (LEFT, UP, DOWN, RIGHT) and its delay (how long the releaser should wait until the next arrow) - Releaser.h
The releaser is responsible for handling specific delay values coded in the arrow sequence for a song, such that arrow are released according to those delay values. These delay values were coded such that the arrows would be synchronized to that particular song, so the releaser is in charge of releasing arrows synchronized to particular rhythms of the song.
Future Improvement
- Upgrading to a multicore microcontroller with more RAM would allow many of the delay issues we encountered to be solved, especially the audio playback issue which caused us to play the audio off a second mbed. Even when downsampled to 8kHz, due to 5-6 threads being run in parallel, the audio delay was very significant and hence was moved to another mbed.
- Integrating a playback buffer for the audio would also have fixed the audio delay problem and would allow the audio to be played without delay or without interruption.
- Finally, designing an algorithm that would dynamically generate arrows according to specific rhythms and tempos would make the code far more efficient and support many more songs for better user experience.
Please log in to post comments.