Created
November 8, 2016 04:00
-
-
Save todocono/1151bc4bee0a8259ef027c576a392123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code example for Animatronics class - NYU Shanghai 2016 | |
// See class details at http://ima.nyu.sh/animatronics | |
// Hardware part required: https://www.dfrobot.com/index.php?route=product/product&product_id=91 | |
// Hardware part required: WiiChuck | |
// Library required hosted at https://github.com/todbot/wiichuck_adapter/tree/master/firmware/WiichuckDemo | |
// Instructions at http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ | |
// Tutorial at http://hacknmod.com/hack/how-to-cheap-accelerometer-using-wii-nunchuck/ | |
#include <math.h> | |
#include "Wire.h" | |
#include "WiiChuck.h" | |
//#include "nunchuck_funcs.h" | |
#define MAXANGLE 90 | |
#define MINANGLE -90 | |
WiiChuck chuck = WiiChuck(); | |
int angleStart, currentAngle; | |
int tillerStart = 0; | |
double angle; | |
void setup() { | |
//nunchuck_init(); | |
Serial.begin(115200); | |
chuck.begin(); | |
chuck.update(); | |
//chuck.calibrateJoy(); | |
} | |
void loop() { | |
delay(20); | |
chuck.update(); | |
Serial.print(chuck.zPressed()); | |
Serial.print(" zPress, "); | |
Serial.print(chuck.cPressed()); | |
Serial.print(" cPress, "); | |
Serial.print(chuck.readJoyX()); | |
Serial.print(" joyX, "); | |
Serial.print(chuck.readJoyY()); | |
Serial.print(" joyY, "); | |
Serial.print(chuck.readRoll()); | |
Serial.print(" roll, "); | |
Serial.print(chuck.readPitch()); | |
Serial.print(" pitch, "); | |
Serial.print((int)chuck.readAccelX()); | |
Serial.print(" Xaccel, "); | |
Serial.print((int)chuck.readAccelY()); | |
Serial.print(" Yaccel, "); | |
Serial.print((int)chuck.readAccelZ()); | |
Serial.print(" Yaccel, "); | |
Serial.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment