Steps making windows application that use WiiMote part two (.NET version)

Steps making windows application that use WiiMote part two

Sorry to leave you wandering those codes I wrote before. I’ll explain it here right now.

If you didn’t read my previous post (Steps make windows application that use WiiMote part two) click here to read.

Here the explaination. First, about the timer1_tick method. That method always loop every 10 ms while your application running. How did I know it loops every 10 ms? You can see properties  of Timer at properties box. The interval has been set 10 ms. Why 10 ms? There is no particular reason though. Just set the interval not too fast or too slow.

Now we validating the wiimote whether it is null (no wiimote detected) or not null.

if(wiimote!= null){

……

}

Before we can read the information from wiimote, we have to get the state of the wiimote.

wiimoteState= wiimote.WiimoteState;


If you want to see what are the attributes that wiimotestate has just type wiimote and then dot ( . ). The IDE will show you.Now you can get all information from your wiimote. This is the list of a fewwiimotestate attribute.

Battery :

The current value of the batteries. The number is
between 0 – 100 floating points;

ButtonState:

Get the current pressed button on wiimote. Return true if the specified button pressed, the  otherwise return false. Example you want to know whether button A is pressed or not;

if(wiimoteState.ButtonState.A){ … }

each button is in the ButtonState class and each return true if the button is pressed (except power and sync button).

AccelState:

Get the accelerometer values. There are 3 values; x, y, and z.

wiimoteState.AccelState.Values

The data type is Point3F.

IRState:

Get all detected IR points. You can get how many points detected, their coordinates, or boolean value detected or not detected.

wiimoteState.IRState.IRSensors
is an array of the detected IR. You can get how

many IR detected by get the length of that array.

wiimoteState.IRState.IRSensors.Length

To know if an IR detected or not:

wiimoteState.IRState.IRSensors[0].Found

The data type is boolean.

it’s coordinate :

wiimoteState.IRState.IRSensors[0].Position

The data type is PointF, that have two values, X and Y.

LEDState:

Get condition of all LED on WiiMote. Return true if the specified LED is on.

Example LED 1, wiimoteState.LEDState.LED1

Extension:

Get condition whether an extension is connected or not.

Rumble:

Get condition whether the wiimote is vibrating or not.

There are more wiimotestates attribute, such as DrumsState, GuitarState, NunchuckState, etc. All of them are states from extension devices like guitar, drum, balance board, nunchuck, classiccontroller, etc.

We have seen the wiimotestate attributes. Those attributes are read-only data. We can’t modify the value, but we can use it for calculation or something else. WiimoteState is only to get information from the wiimote. So, how to give some command to it? I will explain that. But we can only do a few things. Not much.

To see anything that we can do to wiimote, let’s see the attribute and method in it.

wiimote.Connect();

wiimote.Disconnect();

the method above is just to connect and disconnect the wiimote to the program.

wiimote.SetLEDs(intled);

wiimote.SetLEDs(bool led1, bool led2, bool led3, bool led4);

those method are to set what led that we want to turn on. The first method if you want to set which LED number that should be on. Second, if you want to set all of conditions of LED (1 to 4). Example, if you
want to turn the LED on like “ ON OFF ON ON”, you can simply pass the parameters like this:

wiimote.SetLEDs(true,false,true,false);

wiimote.SetRumble(bool on);

As you can see the name of the method, it is for turn the rumble on or off. Just simply pass true or false.

Now you should be understand what the meaning of my codes below :



I will explain some variable from component of my application form.

xProg , yProg, zProg, batteryLevel are progress bar component. They represent the value of wiimotestate attribute. You can see what kind of attribute their represent from my code above.

upChk, bottomChk, leftChk, rightChk are check boxes that
will be checked if we press directional button on wiimote.

rumble is a check box too, if it be checked, the wiimote will vibrating.

led1 to led4 are check boxes too, the LEDs on wiimote will be turned on or off depending on them.

click here to download the source project

thanks for your attention…..

About thejackal

7th semester undergraduate binus university in 2010.
This entry was posted in Binusian Blog. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *