Loading...
Logo
Processing Forum
Hello,

this is my first post and I want to apologize for my English. I'm a 19 years old french student.
I want to apologize for my bad level in processing too :P.
I discovered it thanks to Arduino, and I use it to create interfaces between me (my laptop) and my robot (my arduino).
I am planning to use a wii mote for my robot. I installed all the stuff and: 
IT WORKS!
it works great!

let's talk about my problems.

I can use the "example" project. I understand the result but not how it works (i don't need to re-invent wheels-frenche expression-)

But for my project It would be nice if I could use more features of the wiimote:
-get the battery status
-control the leds
-get the nunchuck acc & joy.

for the moment I am usign this sketch:
http://letsmakerobots.com/node/23723 ( i'm not the autor)

I found this:
http://en.sourceforge.jp/projects/wrj4p5/wiki/Wrj4P5(en) wich seems to be very suitable for my problem.


For the moment I am using this:

Copy code
  1. battery=100*wii.rimokon.getBatteryLevel();
  2. println(battery);


with

Copy code
  1. Wrj4P5 wii;

at the beginning of my sketch.

it sends me 0,29% instead of 44%! (checked with another non-processing method)

So my questions are:

-what have I done wrong with the battery status?

-how can I drive the LEDS?

-Has anyone an exemple of a sketch using wii remote + nunchuck?

Thank you for reading, and sorry I have wrote a lot!

Replies(3)

EDIT: more and more success! still having trouble with led driving, and the battery status doesn't report any error, but the result is not good (2.7% of battery??? I have 52% !)

Answer to myself: I have successfully get the button informations from the nunchuck controller!

here is my code:

Copy code
  1. import lll.wrj4P5.*;

  2. Wrj4P5 wii;

  3. void setup() {
  4.   size(300,300,P3D);
  5.   wii=new Wrj4P5(this);
  6.   wii.connect();
  7. void draw() {
  8.   background(0);
  9.   stroke(255);
  10.   translate(300/2,300/2,0);
  11.   lights();
  12.   rotateX((int) (wii.rimokon.senced.x*30+300));
  13.   rotateY((int) (wii.rimokon.senced.y*30+300));
  14.   rotateZ((int) (wii.rimokon.senced.z*30+300));
  15.   box(100,100,100);
  16. }
  17. void buttonPressed(RimokonEvent evt, int rid) {
  18.    if (evt.wasPressed(RimokonEvent.TWO)) println("2");
  19.    if (evt.wasPressed(RimokonEvent.ONE)) println("1");
  20.    if (evt.wasPressed(RimokonEvent.B)) println("B");
  21.    if (evt.wasPressed(RimokonEvent.A)) println("A");
  22.    if (evt.wasPressed(RimokonEvent.MINUS)) println("Minus");
  23.    if (evt.wasPressed(RimokonEvent.HOME)) println("Home");
  24.    if (evt.wasPressed(RimokonEvent.LEFT)) println("Left");
  25.    if (evt.wasPressed(RimokonEvent.RIGHT)) println("Right");
  26.    if (evt.wasPressed(RimokonEvent.DOWN)) println("Down");
  27.    if (evt.wasPressed(RimokonEvent.UP)) println("Up");
  28.    if (evt.wasPressed(RimokonEvent.PLUS)) println("Plus");
  29. }


  30. void nunchakuPressed(NunchakuEvent evt, int rid)
  31. {
  32.  
  33.   if (evt.wasPressed(NunchakuEvent.Z)) 
  34.   {
  35.     println("Z");
  36.     println(wii.nunchaku.stick.x);  //print the position of the nunchuck joystick (on X axis)
  37.     println(wii.nunchaku.sensed.x);  //print the acceleration of the nunchuck (on X axis)
  38.     println(wii.rimokon.getBatteryLevel());   //print the battery level (still bug, or there is a conversion to do)
  39.     etatled =! etatled ;      //toggle the state of the led
  40.     wii.rimokon.setLED(1, etatled) ;      //DO NOT WORK :( null pointer exception....
  41.    }
  42. }

It was the simple part, because it was very similar to the remote controller exemple code.
But I have no example for the battery status or the LEDs, if anyone could help me...
Did you get this fixed in the end?

I don't know about the Battery life problems you have, but I do have the LEDs working great.

So reply here and let me know if you still need help (6 weeks later!)

S
Hello,

Still having issues with battery and LEDS (I can switch on leds, but its weird, I can't choose wich led to turn on/off)

I have read in Wrj4P5 lib that this is normal that it doesn't work (LED, piezo speaker, battery status and vibration). If I have understood well, it's because wiimote communicate at 100Hz and a Processing sketch can "only" make 60 loop per second.