Educational materials

WiiLAB Example Code - setWiimoteLEDs

Note: MATLAB R2007a or greater is required for this code to run correctly.

Annotations

The setWiimoteLEDs function allows the user to control each of the Wiimote's four LEDs.

Usage

setWiimoteLEDs([on], [on], [on], [on]);

* where 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

Example

The following snippet of code will execute the block inside the if statement and display 'LEDs 1 and 3 are on'.

if ( setWiimoteLEDs(true, false, true, false) )
    disp('LEDs 1 and 3 are on');
end

Raw Source Code

The source code is also available as a .m file download at the bottom of the page.


function setWiimoteLEDs (led1, led2, led3, led4) 
% usage:    setWiimoteLEDs (led1, led2, led3, led4) 
% purpose:  Sets the LEDs on the wiimote
%           led1/2/3/4 are bool values (or 1/0 int) true to turn on rumble, false to turn
%           it off
% note:     initializeWiimote() must be called before calling this function

global wiimote;

% Set the LEDs
wiimote.SetLEDs(led1, led2, led3, led4);

end

r4 - 21 Jul 2008 - 14:20:21 - JessicaSzweda
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Syndicate this site RSSATOM