Collegamento Arduino-Nunchuk Wii

ciao a tutti, vi chiedo un'aiuto per il mio progetto, ovvero di far cambiare direzione ad un motore attraverso l'analogico del nunchuk wii.
questo è il programma per avviare la comunicazione seriale con il nunchuk

#include <Wire.h>

int info[6];
int n = 0;
int tempo=10;
 
void setup()
{
    Serial.begin (9600);
    Wire.begin ();
    Settaggio ();
    Serial.print ("Acquisizione Dati:\n");
}

void Settaggio()
{
    Wire.beginTransmission (0x52);
    Wire.write (0x40);
    Wire.write (0x00);
    Wire.endTransmission ();
}

void Azzera()
{
    Wire.beginTransmission (0x52);
    Wire.write (0x00);
    Wire.endTransmission ();
}

void Scrividati()
{
  int j_x = info[0];
  int j_y = info[1];
  int a_x = info[2]; 
  int a_y = info[3]; 
  int a_z = info[4]; 
  
  int b_z = 1;
  int b_c = 1;
  if ( info[5]       & 1) b_z = 0;
  if ((info[5] >> 1) & 1) b_c = 0;
  if (b_c+b_z == 2) {b_c = 0;}
  else if (b_z == 1){b_c = 1;}
  
  Serial.print ("\t");
 
  Serial.print ("X: ");
  Serial.print (j_x, DEC);
  Serial.print ("\t");
  
  Serial.print ("Y: ");
  Serial.print (j_y, DEC);
    
  Serial.print ("\t");
  Serial.print ("\t");

  Serial.print ("X: ");
  Serial.print (a_x, DEC);
  
  Serial.print ("\t");
  
  Serial.print ("Y: ");
  Serial.print (a_y, DEC);
  
  Serial.print ("\t");
  
  Serial.print ("Z: ");
  Serial.print (a_z, DEC);
    
  Serial.print ("\t");
  Serial.print ("\t");
  
  Serial.print (b_z, DEC);
  
  Serial.print ("\t");
  
  Serial.print (b_c, DEC);
  Serial.print ("\n");

}

void loop()
{
  Wire.requestFrom (0x52, 6);
  while (Wire.available ()) {
    info[n] = Wire.read ();
    n++;
  }
  n = 0;
  Azzera();
  Scrividati();
  delay(tempo);
}

e questo è il programma che uso per far girare il mio motore dc(quello dello starter kit), ma
utilizzando un pushbutton.

int buttonState = 0;

byte pwm;


void setup() {
pinMode(2,OUTPUT);   
pinMode(3,OUTPUT);
pinMode(12,INPUT);   
}

void avanti(byte pwm) {
digitalWrite(2,HIGH);  
analogWrite(3,(255-pwm));   
}

void indietro(byte pwm) {
digitalWrite(2,LOW);
analogWrite(3,pwm);      
}

void fermo() {            
digitalWrite(2,LOW);   
digitalWrite(3,LOW);   
}  

void loop() {
 
  buttonState = digitalRead(12);
  
  if (buttonState == 0)   {
    fermo();
    }
  else   {
   pwm = 255;       
    
    avanti(pwm);
    }
}

come posso fare a far andare in avanti il motore se l'analogico è in avanti, e viceversa se è puntato indietro?

grazie mille in anticipo,

JonnyK