Arduino Dance Dance Revolution
Materials used:
- Arduino Nano 2x
- Breadboard 3x
- Red/Green 8x8 LED Matrix
- Piezo Buzzer
- 1M ohm resistor 2x (capacitor send)
- 220 ohm resistor 2x (capacitor receive)
- Too many wires
- Alligator clips
- 2 Copper plates (can use anything that carries charge as capacitance sensors)
- Cardboard box to house wires/components
- Double-sided tape to mount components in box
Software/Libraries used:
- Arduino IDE
- CapacitiveSensor Library
- pitches.h
Initial Inspiration/Brainstorming
The initial idea for this project was a more traditional Dance Dance Revolution game, utilizing two LED matrices with up/down/left/right input indicators cascading downwards until they reach just above the player character's head (whom we've named Leddy), at which point the player would have to press the corresponding button before the next input reaches Leddy. Due to time and hardware constraints, such as an unwieldy amount of wires and a limited number of Arduino pins, we eventually settled on this simplified version:
First Prototypes
We spent quite a bit of time on this project playing with the LED matrix and learning how to program specific images onto it. The component schematic, which can be found here, shows the following image:
This shows that the matrix has two rows of 12 pins on each side. The pins go in the following order: red, green, ground, red, green, ground, etc. The red/green pins act as "row" pins, and the grounding pins act as "column" pins. In order to light up a specific LED in a row and column, you have to set the row to HIGH, and the column to LOW, in order to complete the circuit and allow the LED to light up. Which pins correspond to which rows and columns are quite unintuitive and we inferred this information through trial and error using alligator clips and the Arduino's 5V and GND pins.
For this project, we chose to only use the green LEDs. After extensive tinkering, we were able to produce this image:
When trying to produce a specific image, you need to employ a "scanning" method, where you very quickly turn the LEDs on and off again, and allow the Arduino to loop fast enough so that the LEDs turning on and off is undetectable to the human eye. This is because setting a column to LOW will complete the circuit for any row that happens to be set to HIGH, even if those specific LEDs are not desired. This can be demonstrated in the code we wrote to display Leddy's arms in the upwards position:
First Input Method
We originally programmed Leddy to be controlled with four simple buttons for the purposes of testing our game logic, shown here:
We used this setup to implement a simple audio output using the Piezo Buzzer and the pitches.h library to produce a "correct" ding and an "incorrect" buzz sound.
Final Input Method
We then began work on using the CapacitiveSensor library to create external input methods, in our case two copper plates. We used these to create left, right, and up inputs, the last of which is produced by hitting both plates at the same time. Due to our dwindling number of pins on the Arduino that programmed the LED display, we decided to use a second Arduino to act solely to handle the capacitive sensing. When the second Arduino senses that a plate has been touched, it sends a signal to one of the first Arduino's digital pins, which is then interpreted as the corresponding pose for Leddy to strike.
(You should probably use electrical tape, not sticky notes. The final version uses electrical tape)
Setup Housing
Once the capacitive sensing inputs worked properly, we created a cardboard box to house the unit.
Since the box is mostly hollow, this gave us the idea that with more time, the box could be converted into something resembling a drum, and the copper plates could act as percussion instruments, essentially having the player create the rhythm in the rhythm game.
Final Demonstration
Known Bugs
There exists a bug, presumably in the game's hardware due to wires in close proximity to each other, unreliable alligator clips, etc, in which certain inputs are interpreted as incorrect erroneously. Sometimes when a series of inputs such as left, left, left, switches to another direction, the second direction is incorrectly interpreted as incorrect even if the player hits the corresponding input. If given more time on this project, we would be able to sort out this bug, but due to time constraints and different pressing school assignments, we've decided to document this bug and turn in the project as is.
Code Repository
If you'd like to take a look at the game's code, either for inspiration or to tell us if there's anything wrong with it (haha), the code run on both Arduinos can be found here.
Comments
Post a Comment