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. /media/uploads/wliu88/screen_shot_2016-04-28_at_3.35.04_pm.png

Picture

/media/uploads/wliu88/img_0978.jpg

Components

Pin Connections

Main mbed

mbed LPC1768uLCD No.1 cable
5V5V
GNDGND
TX = P9TX
RX = P10RX
P16Reset
mbed LPC1768uLCD No.2 cable
5V5V
GNDGND
TX = P28TX
RX = P27RX
P29Reset
mbed LPC1768 Sparkfun Nav Switch Breakout No.1
GND-
P12U
P11C
P13L
P14D
P15R
nc - using internal pullups+
mbed LPC1768 Sparkfun Nav Switch Breakout No.2
GND-
P23U
P22C
P24L
P25D
P21R
nc - using internal pullups+
mbed LPC1768Micro SD Breakout No.1
P8CS
P5DI
VoutVCC
P7SCK
GNDGND
P6DO
\CD

Secondary mbed

mbed LPC1768Micro SD Breakout No.2
P8CS
P5DI
VoutVCC
P7SCK
GNDGND
P6DO
\CD
mbed LPC1768TPA2005D1Speaker
GNDPWR-, IN-
External Power SupplyPWR+
P18IN+
OUT++
OUT--
DO

Connection between two mbeds

main mbed LPC1768secondary mbed LPC1768
songSelected P19P21
specificSong P20P22

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.