merci encore pour votre aide
ok pour les serials
j'ai modifié le code et il marche . j'avais oublier le chuck.update(); après le void loop()
trouvez vous ca normal??
Code PHP:
#include <math.h>
#include "Wire.h"
#include "WiiChuck.h"
#include "LiquidCrystal.h"
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define MAXANGLE 90
#define MINANGLE -90
int pos = 0;
int posX = 0;
WiiChuck chuck = WiiChuck();
int angleStart, currentAngle;
int tillerStart = 0;
double angle;
void setup() {
//nunchuck_init();
lcd.begin(16, 2);
Serial.begin(115200);
chuck.begin();
chuck.update();
//chuck.calibrateJoy();
}
void chuck2servo(){
delay(50);
chuck.update();
pos = chuck.readJoyY();
posX = chuck.readJoyX();
lcd.print("x:");
lcd.print(posX);
lcd.print("y:");
lcd.print(pos);
lcd.print("z:");
lcd.print(chuck.zPressed()?"z_on ":"z_off");
lcd.print(" c:");
lcd.print(chuck.cPressed()?"c_on ":"c_off");
lcd.println();
}
void loop()
{
chuck.update();
//nunchuk.update();
lcd.print(chuck.readJoyX());
lcd.print(' ');
lcd.print(chuck.readJoyY());
lcd.print(' ');
lcd.print(chuck.readRoll());
lcd.print(' ');
lcd.print(chuck.readPitch());
lcd.print(' ');
lcd.print((int)chuck.readAccelX());
lcd.print(' ');
lcd.print((int)chuck.readAccelY());
lcd.print(' ');
lcd.print((int)chuck.readAccelZ());
lcd.println();
lcd.print(chuck.zPressed()?"z1":"z0");
lcd.print(' ');
lcd.print(chuck.cPressed()?"c1":"c0");
lcd.print(' ');
//nunchuk.update();
lcd.setCursor(0, 0);
lcd.print(chuck.readJoyX());
lcd.print(' ');
lcd.print(chuck.readJoyY());
lcd.print(' ');
lcd.print(chuck.zPressed()?"z1":"z0");
lcd.print(' ');
lcd.print(chuck.cPressed()?"c1":"c0");
lcd.print(' ');
lcd.setCursor(0, 1);
lcd.print((int)chuck.readAccelX());
lcd.print(' ');
lcd.print((int)chuck.readAccelY());
lcd.print(' ');
lcd.print((int)chuck.readAccelZ());
lcd.print(' ');
delay(500);
lcd.clear();
}
-----