collapse

* Posts Recentes

O que é isto ? por SerraCabo
[12 de Abril de 2024, 14:20]


Amplificador - Rockboard HA 1 In-Ear por almamater
[11 de Abril de 2024, 20:46]


Emulador NES em ESP32 por dropes
[10 de Abril de 2024, 15:30]


Meu novo robô por josecarlos
[29 de Março de 2024, 18:30]


Bateria - Portátil por almamater
[25 de Março de 2024, 22:14]


Escolher Osciloscópio por jm_araujo
[06 de Fevereiro de 2024, 23:07]


TP4056 - Dúvida por dropes
[31 de Janeiro de 2024, 14:13]


Leitura de dados por Porta Serie por jm_araujo
[22 de Janeiro de 2024, 14:00]


Distancia Cabo por jm_araujo
[08 de Janeiro de 2024, 16:30]


Laser Engraver - Alguém tem? por almamater
[16 de Dezembro de 2023, 14:23]

Autor Tópico: Arduino + nunchuck + 2 servos  (Lida 6361 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline miguelwind

  • Mini Robot
  • *
  • Mensagens: 48
Arduino + nunchuck + 2 servos
« em: 28 de Janeiro de 2010, 19:46 »
Boas.

Já há algum tempo que não posto nada mas agora tenho uma coisa "em mãos" e precisava de ajuda.

É o seguinte:
Já tinha pensado em comprar uns nunchucks para fazer umas brincadeiras e finalmente há umas semanas mandei vir dois do ebay, que estavam a um preço muito bom.

O primeiro problema com que me deparei foi o facto de haverem 5 fios, o que se torna num problema visto que nos tutorias que tenho visto apenas mencionarem 4 fios. Mas como as cores que falam nos tutorias estão todas presentes neste nunchuck, pensei que um dos fios podia não ser necessário (o preto neste caso).

Passado este problema resolvi simplesmente copiar um dos códigos disponíveis para dentro do arduino. Deu logo barraca a compilar e como ainda não percebo muito de programação resolvi passar em diante. Após vários códigos com problemas e já bem mais frustrado comecei a alterar um pouco os códigos apenas confiando na intuição e na lógica. Consegui fazer um código que já passava na compilação mas que depois não fazia o pretendido (aliás, não fazia mesmo nada).

Neste momento estou mais centrado num código que encontrei na net e que também está aqui no fórum. Vou colocar aqui o código tal e qual como encontrei.

Código: [Seleccione]
#include <Wire.h>
#include <string.h>
#include <stdio.h>

uint8_t outbuf[6];

int cnt = 0;
int ledPin = 13;

int servoPin = 7;
int servoPin2 = 6;

int pulseWidth = 0;
int pulseWidth2 = 0;

long lastPulse = 0;
long lastPulse2 = 0;

int z_button = 0;
int c_button = 0;

int refreshTime = 20;

int minPulse = 1000;
int minPulse2 = 500;

int dtime=10;

#define pwbuffsize 10
long pwbuff[pwbuffsize];
long pwbuffpos = 0;
long pwbuff2[pwbuffsize];
long pwbuffpos2 = 0;

void setup()
{
    beginSerial (19200);
    Wire.begin ();
    nunchuck_init ();
    pinMode(servoPin, OUTPUT);
    pinMode(servoPin2, OUTPUT);

    pulseWidth = minPulse;
    pulseWidth2 = minPulse2;
    Serial.print ("Finished setup\n");
}

void nunchuck_init()
{
    Wire.beginTransmission (0x52);
    Wire.send (0x40);
    Wire.send (0x00);
    Wire.endTransmission ();
}

void send_zero()
{
    Wire.beginTransmission (0x52);
    Wire.send (0x00);
    Wire.endTransmission ();
}

int t = 0;

void loop()
{
    t++;
    long last = millis();

    if( t == 1) {

        t = 0;

        Wire.requestFrom (0x52, 6);

        while (Wire.available ()) {
            outbuf[cnt] = nunchuk_decode_byte (Wire.receive ());
            digitalWrite (ledPin, HIGH);
            cnt++;
        }

        if (cnt >= 5) {

            //            printNunchuckData();

            int z_button = 0;
            int c_button = 0;

            if ((outbuf[5] >> 0) & 1)
                z_button = 1;
            if ((outbuf[5] >> 1) & 1)
                c_button = 1;

            switch (c_button) {
            case 1:
                switch (z_button) {
                case 0:
                    break;
                case 1:
                    muovi();
                    break;
                }
                break;
            case 0:
                switch (z_button) {
                case 0:
                    delay(10000);
                    break;
                case 1:
                    delay(3000);
                    break;
                }
                break;
            }
        }

        cnt = 0;
        send_zero();

    } // if(t==)

    updateServo();

    delay(dtime);
}


void updateServo() {

    if (millis() - lastPulse >= refreshTime) {

        digitalWrite(servoPin, HIGH);
        delayMicroseconds(pulseWidth);
        digitalWrite(servoPin, LOW);

        digitalWrite(servoPin2, HIGH);
        delayMicroseconds(pulseWidth2);
        digitalWrite(servoPin2, LOW);

        lastPulse = millis();
    }
}

int i=0;
void printNunchuckData()
{
    int joy_x_axis = outbuf[0];
    int joy_y_axis = outbuf[1];
    int accel_x_axis = outbuf[2]; // * 2 * 2;
    int accel_y_axis = outbuf[3]; // * 2 * 2;
    int accel_z_axis = outbuf[4]; // * 2 * 2;

    int z_button = 0;
    int c_button = 0;

    if ((outbuf[5] >> 0) & 1)
        z_button = 1;
    if ((outbuf[5] >> 1) & 1)
        c_button = 1;
    if ((outbuf[5] >> 2) & 1)
        accel_x_axis += 2;
    if ((outbuf[5] >> 3) & 1)
        accel_x_axis += 1;

    if ((outbuf[5] >> 4) & 1)
        accel_y_axis += 2;
    if ((outbuf[5] >> 5) & 1)
        accel_y_axis += 1;

    if ((outbuf[5] >> 6) & 1)
        accel_z_axis += 2;
    if ((outbuf[5] >> 7) & 1)
        accel_z_axis += 1;

    Serial.print (i,DEC);
    Serial.print ("\t");

    Serial.print ("X: ");
    Serial.print (joy_x_axis, DEC);
    Serial.print ("\t");

    Serial.print ("Y: ");
    Serial.print (joy_y_axis, DEC);
    Serial.print ("\t");

    Serial.print ("AccX: ");
    Serial.print (accel_x_axis, DEC);
    Serial.print ("\t");

    Serial.print ("AccY: ");
    Serial.print (accel_y_axis, DEC);
    Serial.print ("\t");

    Serial.print ("AccZ: ");
    Serial.print (accel_z_axis, DEC);
    Serial.print ("\t");

    Serial.print (z_button, DEC);
    Serial.print (" ");
    Serial.print (c_button, DEC);
    Serial.print ("\r\n");
    i++;
}

char nunchuk_decode_byte (char x)
{
    x = (x ^ 0x17) + 0x17;
    return x;
}

void muovi (){
    float tilt = (700 - outbuf[3]*2*2);
    float tilt2 = outbuf[2]*2*2;

    tilt = (tilt);
    pulseWidth = (tilt * 5) + minPulse;

    tilt2 = (tilt2-288);
    pulseWidth2 = (tilt2 * 5) + minPulse2;

    pwbuff[pwbuffpos] = pulseWidth;
    pwbuff2[pwbuffpos2] = pulseWidth2;
   
    if( ++pwbuffpos == pwbuffsize ) pwbuffpos = 0;
    if( ++pwbuffpos2 == pwbuffsize ) pwbuffpos2 = 0;


    pulseWidth=0;
    pulseWidth2=0;

    for( int p=0; p<pwbuffsize; p++ ){
        pulseWidth += pwbuff[p];
        pulseWidth2 += pwbuff2[p];
    }

    pulseWidth /= pwbuffsize;
    pulseWidth2 /= pwbuffsize;

}


O erro que me deu é o seguinte:

Código: [Seleccione]
o: In function `setup':
C:\Users\Miguel\AppData\Local\Temp\build37314.tmp/sketch_jan28a.cpp:46: undefined reference to `beginSerial'

Pode ser uma coisa muito básica, mas como já disse ainda não percebo muito de programação... :-X

Agradeço qualquer ajuda possível.

Cumps

Offline microbyte

  • Mini Robot
  • *
  • Mensagens: 1.322
    • http://ricardo-dias.com/
Re: Arduino + nunchuck + 2 servos
« Responder #1 em: 28 de Janeiro de 2010, 20:11 »
a sintaxe correcta é Serial.begin()

Offline miguelwind

  • Mini Robot
  • *
  • Mensagens: 48
Re: Arduino + nunchuck + 2 servos
« Responder #2 em: 28 de Janeiro de 2010, 20:59 »
Obrigado Ricardo.  :)

Já não há problemas a compilar. Mas mesmo assim não está a funcionar.  :-\ Consigo enviar para o arduino mas não faz nada. Tentei ver se recebia sinal com o serial monitor mas não consegui ver nada. Estou com a versão 0017 e aquilo está diferente, agora aparece uma caixa cuja utilização ainda não entendi. Para que serve o "send"? Até pode ser o próprio nunchuck. E não é preciso libraries ou coisas do género? Desculpem lá a ignorância, mas já pesquisei consideravelmente e não consegui por isto a funcionar...

Obrigado.
« Última modificação: 30 de Janeiro de 2010, 18:54 por miguelwind »

Offline miguelwind

  • Mini Robot
  • *
  • Mensagens: 48
Re: Arduino + nunchuck + 2 servos
« Responder #3 em: 30 de Janeiro de 2010, 18:56 »
Ninguém consegue dar mais uma ajudinha?  :-[ 

Offline amando96

  • Mini Robot
  • *
  • Mensagens: 1.631
  • MAC address? But I have windows...
    • Projects, News, Blog, Tutorials
Re: Arduino + nunchuck + 2 servos
« Responder #4 em: 30 de Janeiro de 2010, 19:09 »
Puseste o serial monitor a funcionar a 19200 baud?

Offline miguelwind

  • Mini Robot
  • *
  • Mensagens: 48
Re: Arduino + nunchuck + 2 servos
« Responder #5 em: 31 de Janeiro de 2010, 00:36 »
Sim, não recebo nada. Mas para que serve o "send"?

Obrigando pela ajuda.

Offline tcustodio

  • Mini Robot
  • *
  • Mensagens: 344
  • "beware of programmers who carry a soldering iron"
    • Youtube
Re: Arduino + nunchuck + 2 servos
« Responder #6 em: 31 de Janeiro de 2010, 05:05 »
o "send" no Serial Monitor serve para enviares dados para o arduino. Penso que não te servirá para nada, pois não programaste o arduino para reagir dalguma maneira caso lhe mandes alguma coisa.
Tiago Custódio,
- Não me dêem álcool se estiver um piano por perto.

Offline amando96

  • Mini Robot
  • *
  • Mensagens: 1.631
  • MAC address? But I have windows...
    • Projects, News, Blog, Tutorials
Re: Arduino + nunchuck + 2 servos
« Responder #7 em: 17 de Fevereiro de 2010, 20:24 »
chegaste a conseguir? hj chegou o meu, e também tem 5 fios:
branco.
amarelo.
azul.
castanho
vermelho.
como só comprei um não quero arriscar estragar, e esperar mais duas semanas pa chegar outro :P

Offline amando96

  • Mini Robot
  • *
  • Mensagens: 1.631
  • MAC address? But I have windows...
    • Projects, News, Blog, Tutorials
Re: Arduino + nunchuck + 2 servos
« Responder #8 em: 10 de Maio de 2010, 14:32 »
Comprei um original, e consegui por os dois a funcionar :D
  esta parte do código:
Código: [Seleccione]
Wire.beginTransmission (0x52);
    Wire.send (0x40);
    Wire.send (0x00);
    Wire.endTransmission ();

substitui por:
Código: [Seleccione]
byte cnt;

Wire.begin();
           
// init controller
delay(1);
Wire.beginTransmission(0x52); // device address
Wire.send(0xF0);         // 1st initialisation register
Wire.send(0x55);         // 1st initialisation value
Wire.endTransmission();
delay(1);
Wire.beginTransmission(0x52);
Wire.send(0xFB);         // 2nd initialisation register
Wire.send(0x00);         // 2nd initialisation value
Wire.endTransmission();
delay(1);
           
// read the extension type from the register block       
Wire.beginTransmission(0x52);
Wire.send(0xFA);         // extension type register
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.requestFrom(0x52, 6);         // request data from controller
for (cnt = 0; cnt < 6; cnt++) {
    if (Wire.available()) {
        ctrlr_type[cnt] = Wire.receive(); // Should be 0x0000 A420 0101 for Classic Controller, 0x0000 A420 0000 for nunchuck
    }
}
Wire.endTransmission();
delay(1);
           
// send the crypto key (zeros), in 3 blocks of 6, 6 & 4.
Wire.beginTransmission(0x52);
Wire.send(0xF0);         // crypto key command register
Wire.send(0xAA);         // sends crypto enable notice
Wire.endTransmission();
delay(1);
Wire.beginTransmission(0x52);
Wire.send(0x40);         // crypto key data address
for (cnt = 0; cnt < 6; cnt++) {
    Wire.send(0x00);         // sends 1st key block (zeros)
}
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.send(0x40);         // sends memory address
for (cnt = 6; cnt < 12; cnt++) {
    Wire.send(0x00);         // sends 2nd key block (zeros)
}
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.send(0x40);         // sends memory address
for (cnt = 12; cnt < 16; cnt++) {
    Wire.send(0x00);         // sends 3rd key block (zeros)
}
Wire.endTransmission();
delay(1);
// end device init

e declara isto antes do void setup:
Código: [Seleccione]
uint8_t ctrlr_type[6];
o pinout é este:

Não ligues ás cores dos teus fios, estão erradas, pelo menos no meu pirateado estão erradas...


Por isso será isto:
Código: [Seleccione]
/*
 * NunchuckPrint
 *
 * 2007 Tod E. Kurt, http://todbot.com/blog/
 *
 * The Wii Nunchuck reading code is taken from Windmeadow Labs
 *   http://www.windmeadow.com/node/42
 */
 
#include <Wire.h>
uint8_t ctrlr_type[6];

void setup()
{
  Serial.begin(19200);
  nunchuck_setpowerpins(); // use analog pins 2&3 as fake gnd & pwr
  nunchuck_init(); // send the initilization handshake
  Serial.print ("Finished setup\n");
}

void loop()
{
  nunchuck_get_data();
  nunchuck_print_data();
  delay(100);
}


//
// Nunchuck functions
//

static uint8_t nunchuck_buf[6];   // array to store nunchuck data,

// Uses port C (analog in) pins as power & ground for Nunchuck
static void nunchuck_setpowerpins()
{
#define pwrpin PORTC3
#define gndpin PORTC2
    DDRC |= _BV(pwrpin) | _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    PORTC |=  _BV(pwrpin);
    delay(100);  // wait for things to stabilize       
}

// initialize the I2C system, join the I2C bus,
// and tell the nunchuck we're talking to it
void nunchuck_init()
{
byte cnt;

Wire.begin();
           
// init controller
delay(1);
Wire.beginTransmission(0x52); // device address
Wire.send(0xF0);         // 1st initialisation register
Wire.send(0x55);         // 1st initialisation value
Wire.endTransmission();
delay(1);
Wire.beginTransmission(0x52);
Wire.send(0xFB);         // 2nd initialisation register
Wire.send(0x00);         // 2nd initialisation value
Wire.endTransmission();
delay(1);
           
// read the extension type from the register block       
Wire.beginTransmission(0x52);
Wire.send(0xFA);         // extension type register
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.requestFrom(0x52, 6);         // request data from controller
for (cnt = 0; cnt < 6; cnt++) {
    if (Wire.available()) {
        ctrlr_type[cnt] = Wire.receive(); // Should be 0x0000 A420 0101 for Classic Controller, 0x0000 A420 0000 for nunchuck
    }
}
Wire.endTransmission();
delay(1);
           
// send the crypto key (zeros), in 3 blocks of 6, 6 & 4.
Wire.beginTransmission(0x52);
Wire.send(0xF0);         // crypto key command register
Wire.send(0xAA);         // sends crypto enable notice
Wire.endTransmission();
delay(1);
Wire.beginTransmission(0x52);
Wire.send(0x40);         // crypto key data address
for (cnt = 0; cnt < 6; cnt++) {
    Wire.send(0x00);         // sends 1st key block (zeros)
}
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.send(0x40);         // sends memory address
for (cnt = 6; cnt < 12; cnt++) {
    Wire.send(0x00);         // sends 2nd key block (zeros)
}
Wire.endTransmission();
Wire.beginTransmission(0x52);
Wire.send(0x40);         // sends memory address
for (cnt = 12; cnt < 16; cnt++) {
    Wire.send(0x00);         // sends 3rd key block (zeros)
}
Wire.endTransmission();
delay(1);
// end device init
}

// Send a request for data to the nunchuck
// was "send_zero()"
void nunchuck_send_request()
{
  Wire.beginTransmission(0x52); // transmit to device 0x52
  Wire.send(0x00); // sends one byte
  Wire.endTransmission(); // stop transmitting
}

// Receive data back from the nunchuck,
int nunchuck_get_data()
{
    int cnt=0;
    Wire.requestFrom (0x52, 6); // request data from nunchuck
    while (Wire.available ()) {
      // receive byte as an integer
      nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.receive());
      cnt++;
    }
    nunchuck_send_request();  // send request for next data payload
    // If we recieved the 6 bytes, then go print them
    if (cnt >= 5) {
     return 1;   // success
    }
    return 0; //failure
}

// Print the input data we have recieved
// accel data is 10 bits long
// so we read 8 bits, then we have to add
// on the last 2 bits.  That is why I
// multiply them by 2 * 2
void nunchuck_print_data()
{
  static int i=0;
  int joy_x_axis = nunchuck_buf[0];
  int joy_y_axis = nunchuck_buf[1];
  int accel_x_axis = nunchuck_buf[2]; // * 2 * 2;
  int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
  int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

  int z_button = 0;
  int c_button = 0;

  // byte nunchuck_buf[5] contains bits for z and c buttons
  // it also contains the least significant bits for the accelerometer data
  // so we have to check each bit of byte outbuf[5]
  if ((nunchuck_buf[5] >> 0) & 1)
    z_button = 1;
  if ((nunchuck_buf[5] >> 1) & 1)
    c_button = 1;

  if ((nunchuck_buf[5] >> 2) & 1)
    accel_x_axis += 2;
  if ((nunchuck_buf[5] >> 3) & 1)
    accel_x_axis += 1;

  if ((nunchuck_buf[5] >> 4) & 1)
    accel_y_axis += 2;
  if ((nunchuck_buf[5] >> 5) & 1)
    accel_y_axis += 1;

  if ((nunchuck_buf[5] >> 6) & 1)
    accel_z_axis += 2;
  if ((nunchuck_buf[5] >> 7) & 1)
    accel_z_axis += 1;

  Serial.print(i,DEC);
  Serial.print("\t");
 
  Serial.print("joy:");
  Serial.print(joy_x_axis,DEC);
  Serial.print(",");
  Serial.print(joy_y_axis, DEC);
  Serial.print("  \t");

  Serial.print("acc:");
  Serial.print(accel_x_axis, DEC);
  Serial.print(",");
  Serial.print(accel_y_axis, DEC);
  Serial.print(",");
  Serial.print(accel_z_axis, DEC);
  Serial.print("\t");

  Serial.print("but:");
  Serial.print(z_button, DEC);
  Serial.print(",");
  Serial.print(c_button, DEC);

  Serial.print("\r\n");  // newline
  i++;
}

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char nunchuk_decode_byte (char x)
{
  x = (x ^ 0x17) + 0x17;
  return x;
}

para a copia.

e isto:
Código: [Seleccione]
/*
 * NunchuckPrint
 *
 * 2007 Tod E. Kurt, http://todbot.com/blog/
 *
 * The Wii Nunchuck reading code is taken from Windmeadow Labs
 *   http://www.windmeadow.com/node/42
 */
 
#include <Wire.h>

void setup()
{
  Serial.begin(19200);
  nunchuck_setpowerpins(); // use analog pins 2&3 as fake gnd & pwr
  nunchuck_init(); // send the initilization handshake
  Serial.print ("Finished setup\n");
}

void loop()
{
  nunchuck_get_data();
  nunchuck_print_data();
  delay(100);
}


//
// Nunchuck functions
//

static uint8_t nunchuck_buf[6];   // array to store nunchuck data,

// Uses port C (analog in) pins as power & ground for Nunchuck
static void nunchuck_setpowerpins()
{
#define pwrpin PORTC3
#define gndpin PORTC2
    DDRC |= _BV(pwrpin) | _BV(gndpin);
    PORTC &=~ _BV(gndpin);
    PORTC |=  _BV(pwrpin);
    delay(100);  // wait for things to stabilize       
}

// initialize the I2C system, join the I2C bus,
// and tell the nunchuck we're talking to it
void nunchuck_init()
{
  Wire.begin();                 // join i2c bus as master
  Wire.beginTransmission(0x52); // transmit to device 0x52
  Wire.send(0x40); // sends memory address
  Wire.send(0x00); // sends sent a zero. 
  Wire.endTransmission(); // stop transmitting
}

// Send a request for data to the nunchuck
// was "send_zero()"
void nunchuck_send_request()
{
  Wire.beginTransmission(0x52); // transmit to device 0x52
  Wire.send(0x00); // sends one byte
  Wire.endTransmission(); // stop transmitting
}

// Receive data back from the nunchuck,
int nunchuck_get_data()
{
    int cnt=0;
    Wire.requestFrom (0x52, 6); // request data from nunchuck
    while (Wire.available ()) {
      // receive byte as an integer
      nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.receive());
      cnt++;
    }
    nunchuck_send_request();  // send request for next data payload
    // If we recieved the 6 bytes, then go print them
    if (cnt >= 5) {
     return 1;   // success
    }
    return 0; //failure
}

// Print the input data we have recieved
// accel data is 10 bits long
// so we read 8 bits, then we have to add
// on the last 2 bits.  That is why I
// multiply them by 2 * 2
void nunchuck_print_data()
{
  static int i=0;
  int joy_x_axis = nunchuck_buf[0];
  int joy_y_axis = nunchuck_buf[1];
  int accel_x_axis = nunchuck_buf[2]; // * 2 * 2;
  int accel_y_axis = nunchuck_buf[3]; // * 2 * 2;
  int accel_z_axis = nunchuck_buf[4]; // * 2 * 2;

  int z_button = 0;
  int c_button = 0;

  // byte nunchuck_buf[5] contains bits for z and c buttons
  // it also contains the least significant bits for the accelerometer data
  // so we have to check each bit of byte outbuf[5]
  if ((nunchuck_buf[5] >> 0) & 1)
    z_button = 1;
  if ((nunchuck_buf[5] >> 1) & 1)
    c_button = 1;

  if ((nunchuck_buf[5] >> 2) & 1)
    accel_x_axis += 2;
  if ((nunchuck_buf[5] >> 3) & 1)
    accel_x_axis += 1;

  if ((nunchuck_buf[5] >> 4) & 1)
    accel_y_axis += 2;
  if ((nunchuck_buf[5] >> 5) & 1)
    accel_y_axis += 1;

  if ((nunchuck_buf[5] >> 6) & 1)
    accel_z_axis += 2;
  if ((nunchuck_buf[5] >> 7) & 1)
    accel_z_axis += 1;

  Serial.print(i,DEC);
  Serial.print("\t");
 
  Serial.print("joy:");
  Serial.print(joy_x_axis,DEC);
  Serial.print(",");
  Serial.print(joy_y_axis, DEC);
  Serial.print("  \t");

  Serial.print("acc:");
  Serial.print(accel_x_axis, DEC);
  Serial.print(",");
  Serial.print(accel_y_axis, DEC);
  Serial.print(",");
  Serial.print(accel_z_axis, DEC);
  Serial.print("\t");

  Serial.print("but:");
  Serial.print(z_button, DEC);
  Serial.print(",");
  Serial.print(c_button, DEC);

  Serial.print("\r\n");  // newline
  i++;
}

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char nunchuk_decode_byte (char x)
{
  x = (x ^ 0x17) + 0x17;
  return x;
}

para o genuino na nintendo  8)


Cumps!
« Última modificação: 10 de Maio de 2010, 14:49 por amando96 »