Advertisement
Benny1994

Untitled

May 7th, 2022
1,239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <WiiChuck.h>
  2.  
  3. Accessory nunchuck;
  4.  
  5. void setup() {
  6.     Serial.begin(115200);
  7.     nunchuck.begin();
  8.     if (nunchuck.type == Unknown) {
  9.         nunchuck.type = NUNCHUCK;
  10.     }
  11. }
  12.  
  13. void loop() {
  14.   nunchuck.readData();    // Read inputs and update maps
  15.  
  16.   Serial.print("X: "); Serial.print(nunchuck.getAccelX());
  17.   Serial.print(" \tY: "); Serial.print(nunchuck.getAccelY());
  18.   Serial.print(" \tZ: "); Serial.println(nunchuck.getAccelZ());
  19.  
  20.   Serial.print("Joy: (");
  21.   Serial.print(nunchuck.getJoyX());
  22.   Serial.print(", ");
  23.   Serial.print(nunchuck.getJoyY());
  24.   Serial.println(")");
  25.  
  26.   Serial.print("Button: ");
  27.   if (nunchuck.getButtonZ()) Serial.print(" Z ");
  28.   if (nunchuck.getButtonC()) Serial.print(" C ");
  29.  
  30.   Serial.println();
  31.   delay(100);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement