hi to all! i have an ArduinoUNO, and i tried to use this sketch, but it wont work!! why??
/*
- WiiChuckDemo --
- 2008 Tod E. Kurt, http://thingm.com/
*/
#include <Wire.h>
#include "nunchuck_funcs.h"
#include <Servo.h>
Servo olhosim;
Servo olhonao;
Servo boca;
int valorolhosim = 0;
int valorolhonao = 0;
int valorboca = 0;
int loop_cnt=0;
byte accx,accy,accz,zbut,cbut,joyx,joyy;
int ledPin = 13;
void setup()
{
olhosim.attach(8);
olhonao.attach(9);
boca.attach(10);
Serial.begin(19200);
nunchuck_setpowerpins();
nunchuck_init(); // send the initilization handshake
Serial.print("WiiChuckDemo ready\n");
}
void loop()
{
if( loop_cnt > 100 ) { // a cada 100ms, pegue novos dados
loop_cnt = 0;
nunchuck_get_data();
olhosim.write(valorolhosim);
delay(1);
olhonao.write(valorolhonao);
delay(1);
boca.write(valorboca);
accx = nunchuck_accelx();
accy = nunchuck_accely();
accz = nunchuck_accelz();
zbut = nunchuck_zbutton();
cbut = nunchuck_cbutton();
joyy = nunchuck_joyy();
joyx = nunchuck_joyx();
valorolhosim = map(joyy, 0, 250, 0, 179);
delay (1);
valorolhonao = map(joyx, 0, 250, 0, 179);
delay (1);
valorboca = map(accy, 0, 150, 0, 179);
delay (1);
Serial.print("accx: "); Serial.print((byte)accx,DEC);
Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
Serial.print("\taccz: "); Serial.println((byte)accz,DEC);
Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
Serial.print("\tcbut: "); Serial.print((byte)cbut,DEC);
Serial.print("\tjoyx: "); Serial.print((byte)joyx,DEC);
Serial.print("\tjoyy: "); Serial.print((byte)joyy,DEC);
Serial.print("\valorolhosim: ");Serial.print((byte) valorolhosim,DEC);
Serial.print("\valorolhonao: ");Serial.print((byte) valorolhonao,DEC);
}
loop_cnt++;
delay(1);
}