Hi
Goal :
Wireless Wii Nunchuck -> send data to Wii Dongle -> dongle connected to Adruino Nano V3 (ive been able to get other sketches working) -> Adruino Nano V3.0 sends control signals to 2 esc's for bi directional motor control.
Briefly, i volunteer at a disabled sailing club which operates thru out the world, my branch is http://www.sailabilitygc.org - Sailability Gold Coast.
At our club we have a great many disabled sailors (up to 100+ every week) some of them like to take control of the steering or sail control or both.
For this purpose we have winches that operate the control ropes. (sheets for the nautically minded)
Winches are turned on an off with heavy duty micro switches with an Arcade style heavy duty joystick.
And that works ok but as it has to be bolted down and some people cant reach it comfortably.
The wireless Nunchuck is the ideal tool to get around this problem (also opening up the possibility that a quadriplegic sailor might gain some access ability)
(I have a brain injury myself, i have managed to get various sketches to work but need the calibration functions within wiinunchuk.h V0.9 * Author: Tim Teatrodo )
This is the code i have adapted/butchered to purpose.
I can get it to compile and upload to the adruino nano V3 but as yet no movement and the serial monitor is blank.
If you have time would you mind casting your eyes over it and adding any ; or = or - i have missed ?
/*
Written by: Mujahed Altahle
Butchered by : Tony Matthews aka gcebiker
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
*/
/* A Project for Remote Controlling with wireless wii Nunchuck generic brand.
Nuncuck is attached to Gnd, Pwr, scd, scl.
Two ESC's are attached : one to pin 3, one to pin 5 to provide bidirectional dc motor control
The Rx rules is to output the received parameters to port 3 and 6 where the Servo and the ESC are are attached
a condition is required to prevent the controller from transmitting values that is not useful (like 1480-1530 for ESC and 88-92 for Servo) to save more power as much as we can
*/
#include <Wire.h>
#include <Servo.h>
#include <wiinunchuk.h>
Servo escone; // Electronic Speed Controller One declaration
Servo esctwo; // Electronic Speed Controller Two declaration
int pinEscone = 3;
int pinEsctwo = 5;
//
// Setup
//
void setup(void)
{
nunchuk_init();
delay(50);
nunchuk_calibrate_joy();
// i need to be able to program in here a 'dead' spot. to allow for any palsy tremmors the disabled sailors might have.
delay(3000); //wait until the esc starts in case of Arduino got power first
escone.attach(3); // attaches the servo on pin 3 to the servo object
esctwo.attach(5); // attaches the ESC on pin 6 to the ese object
//servo.write(90);
// Print preamble
Serial.begin(57600);
// printf_begin();
}
void loop(){
nunchuk_get_data(); // receives 6 data bytes from controller
if (nunchuk_zbutton() == 1){
// attach servos if not done yet
if (escone.attached() == 0){
escone.attach(3);
};
if (esctwo.attached() == 0){
esctwo.attach(5);
};
delay(5);
// write data to servos
escone.write(3);
esctwo.write(5);
}
}
Sincerely
Tony Matthews
Gold Coast, Australia.