MATLAB Function Reference List
This is intended as a quick reference guide for those writing their own program in MATLAB. All the main WiiLAB functions are briefly described below.
Connection
- initializeWiimote() - Establishes a connection with the Wiimote. Always the first WiiLab function called.
- isWiimoteConnected() - Checks whether the connection attempt was successful. Returns a number to tell which, if any, Wiimote has been connected.
- disconnectWiimote() - Called at the end of every program to terminate the Wiimote's connection and free it up for other programs.
- disconnectAllWiimotes() - Called at the end of a program if multiple Wiimotes have been connected.
Buttons
- isButtonPressed(
'button') - Checks to see if button, the user-specified button on the Wiimote, is currently being pressed.
- Note:
button must be one of the following: A, B, UP, RIGHT, DOWN, LEFT, PLUS, MINUS, HOME, ONE, TWO
- getWiimoteButtons() - Returns an 11-element array that tells whether each of the Wiimote's buttons was pressed at the time of function call.
- Each element in the array corresponds to one of the Wiimote's buttons: [A B UP RIGHT DOWN LEFT PLUS MINUS HOME ONE TWO], respectively.
- Array contains
true for each pressed button and false otherwise.
- isNunchukButtonPressed(
'button') - Checks to see if button, the user-specified button on the Nunchuk, is currently being pressed.
- Note:
button must be one of the following: C, Z
- getNunchukButtons() - Returns a 2-element array that tells whether each of the Nunchuk's buttons was pressed at the time of function call.
- Each element in the array corresponds to one of the Nunchuk's buttons: [C Z], respectively.
- Array contains
true for each pressed button and false otherwise.
Acceleration
- getWiimoteAccel() - Returns the current acceleration values of the Wiimote along each of its 3 axes.
- getNunchukAccel() - Returns the current acceleration values of the Nunchuk along each of its 3 axes.
- initializeWiimoteAccelGraph() - Opens a figure containing 3 sets of axes and continuously graphs the Wiimote's acceleration values in real-time.
- closeWiimoteAccelGraph() - Closes the acceleration graphing figure when it is no longer needed.
- initializeAccelIndicator(
object, velDamping) - Creates a figure containing a graphical representation of the Wiimote's acceleration values.
-
object must be created before this function is called and serves as the tether for the acceleration display.
-
velDamping is an optional parameter that scales the Wiimote's velocity. The default value is 1.
- closeAccelIndicator() - Closes the acceleration indicator figure when it is no longer needed.
IR, Joystick, Battery
- getWiimoteIR() - Returns the position of up to 4 infrared lights in relation to the Wiimote's current position.
- The resulting values are arranged as follows: [X1 Y1 X2 Y2 X3 Y3 X4 Y4]
- getNunchukJoystick() - Returns values indicating the 3-dimensional displacement of the Nunchuk's joystick.
- getWiimoteBattery() - Returns a value indicating the current percentage of battery life left in the Wiimote.
LEDs, Rumble
- setWiimoteLEDs(
on, on, on, on) - Turns the Wiimote's 4 LEDs either on or off, as specified.
- Each
on is either a boolean value (true/false) or an integer (1/0) and corresponds to the subsequent LED from left to right.
-
true or 1 will turn the given LED on. false or 0 will turn the given LED off.
- setWiimoteRumble(
on) - Turns the Wiimote's rumble/vibrate either on or off, as specified.
-
on is either a boolean value (true/false) or an integer (1/0)
-
true or 1 will turn rumble on. false or 0 will turn rumble off.