DDR pad hacking help?
Jadeprince
Posts: 2
So, this is my goal in simple terms: to hack a DDR pad to play music when stepped on.
My challenge: to figure out the proper programming so my basic stamp will accept input from the dance pad.
I'm embarressingly new at this, so please bear with me.
I've got the wiring all done, and I've hacked an old pair of comp speakers to connect into the stamp, but now I'm faced with the challenge of the actually programming.
This is what I've been messing with:
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
INPUT 1
INPUT 2
INPUT 3
INPUT 4
INPUT 6
INPUT 7
INPUT 8
INPUT 9
Main:
SELECT x
CASE x = IN6 'DOWN
DEBUG "Do", CR: FREQOUT 15,150,1047
CASE x = IN4 'UP (pin4)
DEBUG "Re", CR: FREQOUT 15,150,1175
CASE x = IN8 'LEFT
etc. etc. etc...
but... the select/case code doesn't seem to work. Is there a better way to be inputting all the different conditions? Has anyone ever done anything like this before? Any advice would be greatly appreciated. Thank you!
My challenge: to figure out the proper programming so my basic stamp will accept input from the dance pad.
I'm embarressingly new at this, so please bear with me.
I've got the wiring all done, and I've hacked an old pair of comp speakers to connect into the stamp, but now I'm faced with the challenge of the actually programming.
This is what I've been messing with:
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
INPUT 1
INPUT 2
INPUT 3
INPUT 4
INPUT 6
INPUT 7
INPUT 8
INPUT 9
Main:
SELECT x
CASE x = IN6 'DOWN
DEBUG "Do", CR: FREQOUT 15,150,1047
CASE x = IN4 'UP (pin4)
DEBUG "Re", CR: FREQOUT 15,150,1175
CASE x = IN8 'LEFT
etc. etc. etc...
but... the select/case code doesn't seem to work. Is there a better way to be inputting all the different conditions? Has anyone ever done anything like this before? Any advice would be greatly appreciated. Thank you!
Comments
1) You don't have to define pins with INPUT -- this is automatic (INPUT is used to reconfigure a pin that was an output)
2) As you've seen, SELECT-CASE doesn't work with expressions that way
3) If your speakers aren't amplifed, do not connect them directly to the BASIC Stamp or you may damage a pin.· See the Help file or manual in the FREQOUT section for an RC filter that you can put inline with the pin; this will protect the pin and provide smoother tones.
Now ... your app is actually a bit sophisticated.· I've attached a bit of code for you to look at.· It scans the eight inputs (connected to P0 - P7 for coding convenience) and returns a value in xKeys that indicates which keys just got pressed.· The main loop of the program scans through the pressed keys and plays the note -- but just one at a time (no chords).
The program could be updated to play two tones at one time, but this even trickier.· Once you get this version working then you can move on to that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
And my speakers are okay, I've used them before to output tones from keyboard input (that's what got me interested in using microcontrollers to make music). But thanks for the warning.