Introduction: Wii Remote Laser Saber Effects

About: Imagineer and investigator of technology follow me on: twitter @Beackmaniax

I will show you how to make your own “Wii Remote Space Pirate Sword Sound Effects.PIE Script”.

This is not a prop it is to make your WiiMote sound like a saber when connected to a PC.

I've came out with this instructable 'cause I wanted to know how to use the Wii Remote in different ways.

I already did an instructable showing you how to make a DIY head mouse for people with other abilities (which I’ll be updating soon).

This instructable will teach you how to pair sounds, vibration, etc. to your Wii Remote in order to make sound vibrating effects just by hovering this device with your hand.

Step 1: What Do We Need?

As Lucas Ltd. is the owner of all relating sound effects and names regarding StarWars like Light Saber, I tried to find opensource sounds and effects for this script, but you can use other sounds like real sword swings etc.

The sources and materials are these:

  1. Open Source Space Sword Sound Effects. (Search Google)
  2. Wii Remote. (eBay 13 dollars)
  3. Bluetooth Dongle Device. (eBay 8 dollars)
  4. GlovePIE Program. (It is Freeware Search Google)

If you don't want to make all the steps and just want the Wii_Remote_Space_Sword_Effects_Script.PIE script and PIE software go to Step 8

Step 2: Connecting Wii Remote and Software

Connect and install the Bluetooth drivers and software.
Add the Wii Remote Device Connection to your PC.
Uncompress and Copy the GlovePIE Program to a new folder.

Step 3: Testing Wii Remote Connection

Test your Wii Remote connection:

1 Pair your Wii Remote
2 Immediately start GlovePIE.exe
3 In the program do: File

If is all correct you will be able to check your Wii Remote connection also you will see the script of the TestWiimote.PIE which contain all the commands of your Wii Remote.

Step 4: Commands and Variables

Command scripts:

wiimote buttons:

Up = Wiimote.Up
Down = Wiimote.Down
Left = Wiimote.Left
Right = Wiimote.Right
A = Wiimote.A
B = Wiimote.B
One = Wiimote.One
Two = Wiimote.Two
Home = Wiimote.Home
Minus = Wiimote.Minus
Equals = Wiimote.Plus

Example: Rumble when shift is pressed
Wiimote.Rumble = Shift

Example: Set the middle two LEDs to ON
Wiimote.Led1 = false
Wiimote.Led2 = true
Wiimote.Led3 = true
Wiimote.Led4 = false

Example: Show the IR dots as fake cursors
Cursor1.Visible = Wiimote.dot1vis
Cursor1.x = Wiimote.dot1x / 1023
Cursor1.y = Wiimote.dot1y / 1023

Cursor2.Visible = Wiimote.dot2vis
Cursor2.x = Wiimote.dot2x / 1023
Cursor2.y = Wiimote.dot2y / 1023

Cursor3.Visible = Wiimote.dot3vis
Cursor3.x = Wiimote.dot3x / 1023
Cursor3.y = Wiimote.dot3y / 1023

Cursor4.Visible = Wiimote.dot4vis
Cursor4.x = Wiimote.dot4x / 1023
Cursor4.y = Wiimote.dot4y / 1023

Step 5: Programming Language and Scripting

Programming language and Scripting

The programming language is the one will help us to make the Wii Remote do what we what it to do and the Scripting is the action of using it into a PIE (Programmable Input Emulator).

It is composed of simple commands that seem like if you were talking with your Wii Remote for example: it is like if we said: Wii Remote “if” this button is pressed “then” play this sound and vibrate 3 seconds, “endif” this other thing happens (the commands “if” “then” and “endif” are the most common in the programming languages)

To make it more understandable I will show you a real script and then I will describe it:

if var.rmbl = false then

debug = "Press minus to turn on your Sword"

endif

if var.rmbl = true then

debug = "Swing, or Hold Down, right or left to change sound effects. Press plus to stop"

Endif

The Wii Remote will send to the debug dialog box "Press minus to turn on your Saber" while the variable “var.rmbl” it’s false but if it get’s true (by using other command like “if wiimote.plus = 1 then var.rmbl = true”), then the debug dialog box will change to “Swing, or Hold Down, right or left to change sound effects. Press plus to stop"

I know it’s confusing at the beginning, but over practice it will be easy for you to do any scripting.

Step 6: Space Sword Scripting


I would like to teach you step by step how to program but it would take me hours. So I will try to teach you over the scripting.

Scripting Start

Here we will set the Wii Remote variables we will use (like the motion sensing), and are represented by a “var.”

Script:

var.xOffset = 0

var.yOffset = -17

var.zOffset = -10

var.xRot = Wiimote.RawForceX + var.xOffset

var.yRot = Wiimote.RawforceY + var.yOffset

var.zRot = Wiimote.RawforceZ + var.zOffset

Wiimote.leds = 0

Then we will set the commands and scripts that the Wii Remote will follow at the beginning:

Script:

if var.rmbl then

wiimote.Rumble = 1

wait 1 ms

wiimote.Rumble = 0

wait var.time ms

endif

if var.rmbl = false then

debug = "Press B to turn on your Sword"

endif

if var.rmbl = true then

debug = "Swing. Hold B or Right to change sound effects. Press A to stop."

endif

if (wiimote.plus) + (var.on = 0) then

playsound("Sword Sounds\on0.wav")

var.time = 25

var.rmbl = true

wait(1.55s)

var.on = 1

var.soundon = 1

endif

if var.soundon = 1

playsound("Sword Sounds\idle0.wav")

var.time = 100

wait(452ms)

endif

if wiimote.minus + (var.on = 1) then

playsound("Sword Sounds\off0.wav")

var.on = 0

var.soundon = 0

var.time = 200

wait(0.5s)

var.rmbl= false

endif


Then we will add the commands to follow after the saber is activated like motion sensing swing sounds and crashing effects.

Script:

if (var.yrot > 20) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingy = 1
playsound("
Sword Sounds\sthswng1.wav")
wait(0.9s)
var.swingy = 0
endif

if (var.xrot > 20) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingx = 1
playsound("
Sword Sounds\sthswng3.wav")
wait(0.64s)
var.swingx = 0
endif

if (var.yrot > 30) + (var.on = 1) + (wiimote.b = 1) + (wiimote.down = 0) then
var.swingy = 1
playsound("
Sword Sounds\Swing02.wav")
wait(0.9s)
var.swingy = 0
endif

if (var.xrot > 50) + (var.on = 1) + (wiimote.b = 1) + (wiimote.down = 0) then
var.swingx = 1
playsound("
Sword Sounds\sthtwrl2.wav")
wait(0.64s)
var.swingx = 0
endif

if (var.yrot > 40) + (var.on = 1) + (wiimote.left = 1) then
playsound("
Sword Sounds\strike0.wav")
var.strikey = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.38s)
var.strikey = 0
endif

if (var.xrot > 30) + (var.on = 1) + (wiimote.left = 1) then
playsound("
Sword Sounds\strike1.wav")
var.strikex = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.23s)
var.strikex = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.left = 1) then
playsound("
Sword Sounds\strike2.wav")
var.strikez = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.27s)
var.strikez = 0
endif

if (var.yrot > 40) + (var.on = 1) + (wiimote.down = 1) then
playsound("
Sword Sounds\hit0.wav")
var.hity = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(1.25s)
var.hity = 0
endif

if (var.xrot > 30) + (var.on = 1) + (wiimote.down = 1) then
playsound("
Sword Sounds\hit3.wav")
var.hitx = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.45s)
var.hitx = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.down = 1) then
playsound("
Sword Sounds\hit1.wav")
var.hitz = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.8s)
var.hitz = 0
endif

if (var.yrot > 40) + (var.on = 1) + (wiimote.right = 1) then
playsound("
Sword Sounds\LSwall01.wav")
var.hity = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(1.25s)
var.hity = 0
endif

if (var.xrot > 30) + (var.on = 1) + (wiimote.right = 1) then
playsound("
Sword Sounds\LSwall02.wav")
var.hitx = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.45s)
var.hitx = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.right = 1) then
playsound("
Sword Sounds\LSwall02.wav")
var.hitz = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.8s)
var.hitz = 0
endif

Then we will add the commands to stop previous commands activated by the motion sensing commands.

Script:

if (var.swingy or var.swingx or var.swingz or var.strikey or var.strikex or var.strikez or var.hity or var.hitx or var.hitz) = 1 then
var.soundon = 0
else if var.on = 1
var.soundon = 1
endif

Step 7: Step 7 Running Script

Once you have finished your script:

  1. Compile it to find any errors doing: Run
  2. Save it with the name you want.
  3. Pair your Wii Remote with the PC.
  4. Then just open your script and enjoy it by running it: Run
  5. If the steps were successful you will be able to swing and feel the power of a Space Sword !!!

Step 8: Quick Guide and Links

Quick Guide

1.-Download PIE Program
2.-Download Wii Remote Space Sword Script and Sounds
3.-UnZip PIE program
4.-Pair the wii Remote to the PC
5.-Run PIE Program
6.-UnRar "Wii Remote Space Sword Script and sound efects folder" to the same folder
7.-Open the .PIE script on the PIE program
8.-Run and enjoy

Softwere and Script links:

GlovePIE Software

Space Sword Script

Space Sword Sounds

I invite you to upload and share your Scripts in the comments section. happy Scripting !!!

Heroes and Villains Contest

Participated in the
Heroes and Villains Contest

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016