Instructables

Wiimote Rubens Tube: Control Fire With Sound! (And a Nintendo Wiimote!)

Featured

Step 10: Auxillary: GlovePie Script

Picture of Auxillary: GlovePie Script
This is the script I wrote the work with Mixx and GlovePie. Many thanks to Carl Kenner, the creator of GlovePie and the creators of Mixx. Granted, I'm positive this code can be greatly cleaned up, but it works and is quite fun to play with. Post back here if you have problems with the code or programs.

Again, the controls are:

  • Volume: Hold down A- vertical tilt is up/down and swinging up/down moves it fast to some degree of accuracy.
  • Speaker Balance: Hold down B- swing left/right
  • Track Speed: D-Pad left and right
  • Play Track One/Two- D-Pad Up and Down
  • Momentary Bass Boost- (for flame jump) The "1" Button

\\\\\\\\\\\\Code Begins Now\\\\\\\\\\\\\\\\\\\

pie.FrameRate= 600Hz
debug = "angle="+Wiimote.pitch

/*An attempt to fling volume up and down quickly with gestures.
works okay but needs some refinement*/

var.MoveUp = Wiimote.RelAccy > 7, Wiimote.RelAccy < -7
var.MoveDown = Wiimote.RelAccy < -7, Wiimote.RelAccy > 7

if (wiimote.A= true) and (keepdown(var.MoveUp=true,700ms)) then
key.p=true
wait 1ms
key.p= false
endif

if (wiimote.A= true) and (keepdown(var.MoveDown=true,700ms)) then
key.l=true
wait 1ms
key.l= false
endif

//Gradual Volume up/down

if ( 0 < wiimote.Pitch) and (wiimote.A=true) then
key.P = true
wait 50ms
key.p= false
endif

if ( 0 > wiimote.pitch) and (wiimote.A=true) then
key.l =true
wait 50ms
key.l=false
endif

//rate of music and if sine wave, make scroll by varying pitch

if keepdown(wiimote.Left=true, 120ms)
key.F1=true
wait 40 ms
key.F1=false
endif
if keepdown(wiimote.Right=true, 120ms)
key.F2=true
wait 40 ms
key.F2=false
endif

//Bass Jump for Flame Jump
if pressed(Wiimote.1) then var.PressTimes = 30
if var.PressTimes > 0 then
Press key.c
wait 1ms
Release key.c
var.PressTimes = var.PressTimes - 1
endif

if released(Wiimote.1) then var.PressTimes2 = 30
if var.PressTimes2 > 0 then
Press key.x
wait 1ms
Release key.x
var.PressTimes2 = var.PressTimes2 - 1
endif

//Play start/stop
key.d= wiimote.up
key.b=wiimote.down

//Left and Right Balance- Swinging

var.MoveRight = Wiimote.RelAccX > 9, Wiimote.RelAccX < -9
var.MoveLeft = Wiimote.RelAccX < -9, Wiimote.RelAccX > 9

if (wiimote.B= true) and (keepdown(var.MoveRight=true,300ms)) then
key.M=true
wait .5ms
key.M= false
endif

if (wiimote.B= true) and (keepdown(var.Moveleft=true,300ms)) then
key.n=true
wait .5ms
key.n= false
endif

/*Resetting the balance, if all the way left or right, plus
and minus reset the balence to center respectively. I debated
using the multiple press variable as used in the Bass jump, but
the code ended up being longer and more complex than this...which
does the job.
*/

if (pressed(wiimote.Minus)) and (wiimote.B=true) then
press key.n
wait 1ms
release key.n
press key.n
wait 1ms
release key.n
press key.n
wait 1ms
release key.n
press key.n
wait 1ms
release key.n
press key.n
wait 1ms
release key.n
endif

if (pressed(wiimote.Plus)) and (wiimote.B=true) then
press key.M
wait 1ms
release key.M
press key.M
wait 1ms
release key.M
press key.M
wait 1ms
release key.M
press key.M
wait 1ms
release key.M
press key.M
wait 1ms
release key.M
endif

\\\\\\\\\\Code Ends Now\\\\\\\\\\\\\\\\\
 
Remove these adsRemove these ads by Signing Up