I use the C button to achieve 0.5x speed, the Z button gives me 1.5x speed and pushing both together resets the speed back to 1x. I made some mods to the code to incorporate a dynamic speed control using the C and Z buttons. Tilt based on the input from the joystick Map the x/y value to get the full range Vary = chuck.readJoyY() // nunchuk.analogY is the value of the y-axisĪbsx = abs(varx) // Convert the x-axis value to an absolute value Varx = chuck.readJoyX() // nunchuk.analogX is the value of the x-axis 130 is the distance from 0 on the joystick Nunchuck_setpowerpins() // use analog pins 2 & 3 as gnd & pwr (uncomment to use WiiChuck)ĭelay(100) // wait for things to stabilizeĬhuck.update() // The Nunchuck values update in the loop TCCR2B = TCCR2B & 0b11111000 | 0x07 // Adjusting PWM frequencies for testing pins 11 and 3
Serial.begin(115200) // Opening the serial port Int varx, vary, absx, absy, mapx, mapy = 0 #define down 9 // Pin 9 controls down tilt #define right 3 // Pin 3 controls right pan #define left 11 // Pin 11 controls left pan #include "WiiChuck.h" // The library used by the Nunchuck * I am not responsible for any damage that may occur from the use of this software. * You should have received a copy of the GNU General Public License * GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* but WITHOUT ANY WARRANTY without even the implied warranty of * This program is distributed in the hope that it will be useful, * the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by * This program is free software: you can redistribute it and/or modify * This sketch controls the Bescor MP-101 Pan/Tilt system using the Wii Nunchuck