Intro: Simple Guitar Hero Controller for PC Using Teensy (Capable of Multi-player)
After making the Simple taped up DDR Pad, the natural next step is obviously a guitar hero controller :)
What I realized is I will run out of pins on my board if I wanted to add more players.
Using analog value, which means I only need one analog pin for the four buttons.
The best part:
It was a lot easier to construct.
Since only a small number of pins are needed, I decided to pick up a teensy for this project
R2R Ladder and why it works
R2R Ladder and why it's not a good idea
Resistors don't always come with the value you want o.o
How to use teensyduino on Windows
Step 1: Gathering Materials
1. Four Push buttons
Can pick them up from any electronics store. I used the ones that came with my Arduino kit from Sparkfun
2. teensy or Arduino Leonardo for easy USB integration
- These boards can be used as Keyboard/mouse directly, but any other boards will work too assuming you know what to do :) (Create a program to translate serial input into keyboard actions)
I ended up using 3x 4.7k resistors and 8x10k resistors.
(Ideally, 5k resistors should be used, I did not know that I didn't have them!)
A short length for each button - Ground connection
A long length for each button - For connecting to the R2R ladder
Three super long wires for connecting to the board
Again, I have limitations, this project was simple enough for a breadboard, feel free to use whatever you feel comfortable
5. Optional Reading
Resistor Ladder Explanation
Step 2: Building the R2R Ladder
R2R Ladder is a type of DAC (Digital-Analog Converter)
Its purpose is to translate a digital signal (ie. my button presses into an analog value)
Its role in this project is to save me some digital pins
Here's a good explanation on how it works
Build the R2R Ladder circuit on the breadboard
Note again I used 10k and 4.7k resistors when 10k and 5k resistors would have made calculation a lot easier
Step 3: Add Buttons to the Circuit
Build the circuit with the buttons using your pushbuttons and 10k resistors
Note with the Sparkfun buttons, the two pins that are closer together should be on the same side
Step 4: Connect the Buttons to the R2R Ladder
Connect the buttons to the R2R Ladder, each button should connect to a 10k Resistor
Step 5: Connect Board to Teensy/Arduino
I'm using the same image as the last step
This is where the long wires comes in
Connect Yellow to A0 on Teensy/Arduino
Red Power to 3.3V output on Teensy/Arduino
Blue Ground to Gnd on Teensy/Arduino
Step 6: Teensy Code
Here's the code made for my teensy
Notice the line float values?
That's because I didn't have perfectly matching resistors so the values could not be easily obtained from the analog value.
What I ended up doing was record all the combinations and the corresponding analog values
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
Feel free to modify if needed. My data was recorded using 3.3V output. I imagine 5V would produce slightly different output values
Step 7: Upload Code Using Arduino IDE and Play
Upload code and play
Secure the connection between the breadboard and your teensy/arduino board
Optionally you can create a guitar like body.
I haven't found anything easy for it just yet
Will update when I come across something
Now, load up stepmania and play!
Step 8: Troubleshooting Teensyduino
Here's the full link
The short summary is:
1) On Windows, make sure teensy drivers are installed
2) Serial port will not work unless the code has been uploaded
3) If serial port is still grayed out, sometimes, closing Arduino IDE, unplug teensy and plugging it back in and then start Arduino IDE will help.