wii nunchuck to arduino to max/processing

Hey just wanted to share. got a nunchuck sending data to processing and max. here's the codes, which are all codes I got elsewhere and altered to make them work together:

arduino

#include 
#include "nunchuck_funcs.h"

int loop_cnt=0;

byte accx,accy,accz, zbut,cbut,joyy, joyx;

void setup()
{
    Serial.begin(115200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
    
    //Serial.print("Wii Gonna Fug It Up\n");
    
    
}

  void loop()
{  
  if( loop_cnt > 50 ) { // every 100 msecs get new data
        loop_cnt = 0;

        nunchuck_get_data();

        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        accy  = nunchuck_accely(); // ranges from approx 65 - 173
        accz  = nunchuck_accelz(); // ranges from approx 65 - 173
        zbut = nunchuck_zbutton();
        cbut = nunchuck_cbutton(); 
        joyy = nunchuck_joyy();
        joyx = nunchuck_joyx();   
        
       
        Serial.print(accx, DEC);
        Serial.print(",");
        Serial.print(accy,DEC);
        Serial.print(",");
        Serial.print(accz,DEC);
        Serial.print(",");
        Serial.print((byte)zbut,DEC);
        Serial.print(",");
        Serial.print((byte)cbut,DEC);
        Serial.print(",");
        Serial.print(joyx,DEC);
        Serial.print(",");
        Serial.println(joyy,DEC);
        
        
        
    }
    
    
      
  loop_cnt++;
    delay(1);  
}

processing:

import processing.serial.*;


float accx,accy,accz,zbut,cbut,joyy,joyx;


Serial myPort;

void setup()
{
  size(600, 600);
  
  println(Serial.list());

  //port = new Serial(this, "COM1", 9600);
  // Uses the first available port
  myPort = new Serial(this, Serial.list()[0], 19200);
  myPort.bufferUntil('\n');

}

void draw()
{
    
  }





void serialEvent(Serial myPort) { 
  String inString = myPort.readStringUntil('\n');

  if (inString != null) {
    inString = trim(inString);
    float[] wii = float(split(inString, ","));
    if (wii.length >=7) {
     accx=wii[0];
     accy=wii[1];
     accz=wii[2];
     zbut=wii[3];
     cbut=wii[4];
     joyx=wii[5];
     joyy=wii[6];
    }
  }
}

and the max patch

#P window setfont "Sans Serif" 9.;
#P flonum 332 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 332 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 332 438 49 196617 change 0;
#B color 14;
#P flonum 390 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 390 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 390 438 49 196617 change 0;
#B color 14;
#P flonum 214 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 214 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 214 438 49 196617 change 0;
#B color 14;
#P flonum 156 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 156 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 156 438 49 196617 change 0;
#B color 14;
#P flonum 96 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 96 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 96 438 49 196617 change 0;
#B color 14;
#P flonum 33 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 33 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 33 438 49 196617 change 0;
#B color 14;
#P newex 137 377 170 196617 unpack i i i i i i i i i i i i i;
#P message 19 194 20 196617 13;
#P newex 65 193 31 196617 spell;
#P newex 19 167 56 196617 trigger b l;
#P newex 137 159 43 196617 delay 4;
#P button 137 185 15 0;
#P message 19 144 14 196617 r;
#P window setfont "Sans Serif" 10.;
#P comment 221 353 141 196618 
Combine into one value;
#P comment 221 326 141 196618 Convert to integers;
#P window setfont "Sans Serif" 9.;
#P newex 137 351 64 196617 fromsymbol;
#P newex 137 325 40 196617 itoa;
#P newex 137 298 61 196617 zl group 78;
#P newex 137 264 67 196617 select 10 13;
#P window setfont "Sans Serif" 10.;
#P comment 203 22 90 196618 serial port select;
#P window setfont "Sans Serif" 9.;
#P user ubumenu 233 41 29 196617 0 1 1 0;
#X add a;
#X add b;
#X add c;
#X add d;
#X add e;
#X add f;
#X prefix_set 0 0  0;
#P button 315 41 15 0;
#P button 19 119 15 0;
#P newex 233 70 67 196617 prepend port;
#P window setfont "Sans Serif" 10.;
#P window linecount 2;
#P comment 102 70 101 196618 sample rate (15ms -- 100ms);
#P window setfont "Sans Serif" 9.;
#P number 61 70 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user hslider 63 38 19 111 86 1 15 0;
#P toggle 19 42 15 0;
#P window linecount 1;
#P newex 19 96 55 196617 metro 10;
#P newex 137 236 110 196617 serial b 115200 8 1 0;
#P message 315 70 32 196617 print;
#P window setfont "Sans Serif" 10.;
#P comment 312 22 86 196618 list serial ports;
#P comment 9 22 47 196618 On/Off;
#P comment 221 267 174 196618 Ascii character 10 = CR \, 13 = LF;
#P comment 221 301 141 196618 Group characters until LF;
#P window setfont "Sans Serif" 9.;
#P flonum 274 463 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 274 414 46 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 274 438 49 196617 change 0;
#B color 14;
#P connect 44 0 46 0;
#P connect 45 0 44 0;
#P connect 31 12 45 0;
#P connect 47 0 49 0;
#P connect 48 0 47 0;
#P connect 31 10 48 0;
#P connect 16 0 7 0;
#P connect 0 0 2 0;
#P connect 1 0 0 0;
#P connect 31 8 1 0;
#P connect 17 0 14 0;
#P connect 41 0 43 0;
#P connect 42 0 41 0;
#P connect 31 6 42 0;
#P connect 38 0 40 0;
#P connect 39 0 38 0;
#P connect 31 4 39 0;
#P connect 22 0 31 0;
#P connect 21 0 22 0;
#P connect 20 0 21 0;
#P fasten 19 2 20 0 198 290 142 290;
#P fasten 19 1 20 0 170 290 142 290;
#P connect 8 0 19 0;
#P fasten 14 0 8 0 238 223 142 223;
#P fasten 7 0 8 0 320 223 142 223;
#P fasten 30 0 8 0 24 223 142 223;
#P fasten 29 0 8 0 70 223 142 223;
#P connect 26 0 8 0;
#P connect 27 0 26 0;
#P connect 15 0 25 0;
#P fasten 15 0 27 0 24 139 142 139;
#P connect 35 0 37 0;
#P connect 36 0 35 0;
#P connect 31 2 36 0;
#P connect 28 1 29 0;
#P connect 12 0 9 1;
#P fasten 11 0 12 0 68 60 66 60;
#P connect 32 0 34 0;
#P connect 33 0 32 0;
#P connect 31 0 33 0;
#P connect 28 0 30 0;
#P connect 25 0 28 0;
#P connect 9 0 15 0;
#P connect 10 0 9 0;
#P window clipboard copycount 50;

it seems to work the best with max, if you select an unused port, then select the correct port, which should be "a", and then press reset on the arduino.

and the nunchuck library:

/*
 * WiiChuck_funcs.h -- Arduino library to use the WiiChuck
 * --------------
 *
 * Based on original code BlinM_funcs.h by Todd E. Kurt (todbot.com) 
 *
 * Note: original version of this file lives with the WiiChuckTester sketch
 *
 *
 */

#include 


typedef struct _WiiChuck_script_line {
    uint8_t dur;
    uint8_t cmd[4];    // cmd,arg1,arg2,arg3
} WiiChuck_script_line;


// Call this first (when powering WiiChuck from a power supply)
static void WiiChuck_begin()
{
    Wire.begin();                // join i2c bus (address optional for master)
}

// General version of WiiChuck_beginWithPower().
// Call this first when WiiChuck is plugged directly into Arduino
static void WiiChuck_beginWithPowerPins(byte pwrpin, byte gndpin)
{
    DDRC |= _BV(pwrpin) | _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    PORTC |=  _BV(pwrpin);
    delay(100);  // wait for things to stabilize

    Wire.begin();
}

// Call this first when WiiChuck is plugged directly into Arduino
static void WiiChuck_beginWithPower()
{
    WiiChuck_beginWithPowerPins( PC3, PC2 );
}

// sends a generic command
static void WiiChuck_sendCmd(byte addr, byte* cmd, int cmdlen)
{
    Wire.beginTransmission(addr);
    for( byte i=0; i