3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Electric Canoe

Step 3Electronics

Electronics


Here is the arduino code I used:

WiiChuck.h and ServoTimer1.h are both available on-line. Drop a message if you want them and cant find them.

******************

#include "Wire.h"
#include "WiiChuck.h"
#include "ServoTimer1.h"

#define TILL_POWER_PIN 8
#define TILL_STBD_PIN 10
#define TILL_PORT_PIN 9

#define THROTT_DIFF_PIN 12
#define THROTT_MAIN_PIN 11

#define MINTILLPULSE 1100 // Minimum servo position
#define MAXTILLPULSE 1900 // Minimum servo position

#define MINTHROTTPULSE 1000 // Minimum servo position
#define MAXTHROTTPULSE 1965 // Maximum servo position

//ServoTimer1 tiller = ServoTimer1();
WiiChuck chuck = WiiChuck();

int tillerPulse = 1500; // Amount to pulse the servo
int throttlePulse = 1500; // Amount to pulse the servo

int throttleDiffPulse = 1500; // Amount to pulse the servo

int lastTillerPulse = 1500;
int baseTillerPulse = 1500;

int move = 10;

long lastPulse = 0; // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0; // the value returned from the analog sensor
int analogPin = 0; // the analog pin that the sensor's on

boolean wake = true;
long sleeptimer = 0;
boolean dothrottle = true;

void setup() {

Serial.begin(9600);
chuck.begin();
chuck.update();
//tiller.setMaximumPulse(2500);
//tiller.setMinimumPulse(500);

for (int i =8; i<13;i++) {
pinMode(i, OUTPUT); // Set servo pin as an output pin
}
}

int angle;
void loop() {

chuck.update();
lastTillerPulse = tillerPulse;

if (chuck.buttonC) {
//tiller.attach(9);
//tiller.write(angle);
//tiller.attach(10);
//tiller.write(angle);
baseTillerPulse = (int)(1500.0 - chuck.readRoll() * 3);
throttleDiffPulse = (int)(1500.0 + chuck.readJoyX() * 5);
tillerPulse = baseTillerPulse;
}
else {
if (abs(chuck.readJoyX()) > 10) {
tillerPulse = baseTillerPulse - chuck.readJoyX();
}
else {
tillerPulse = baseTillerPulse;
}
}

if (chuck.buttonZ) {
throttlePulse = (int)(1500.0 + chuck.readJoyY() * 5);

}

if (throttlePulse < MINTHROTTPULSE) {
throttlePulse = MINTHROTTPULSE;
}
if (throttlePulse > MAXTHROTTPULSE) {
throttlePulse = MAXTHROTTPULSE;
}

if (throttleDiffPulse < MINTHROTTPULSE) {
throttleDiffPulse = MINTHROTTPULSE;
}
if (throttleDiffPulse > MAXTHROTTPULSE) {
throttleDiffPulse = MAXTHROTTPULSE;
}

if (tillerPulse < MINTILLPULSE) {
tillerPulse = MINTILLPULSE;
}
if (tillerPulse > MAXTILLPULSE) {
tillerPulse = MAXTILLPULSE;
}

Serial.print(tillerPulse);
Serial.print(", ");
Serial.println(throttlePulse);

if (tillerPulse != lastTillerPulse) {
wake = true;
sleeptimer = 0;
}
else {
sleeptimer += 1;
}

if (sleeptimer > 80)
wake = false;

if (wake) {
digitalWrite(TILL_POWER_PIN, HIGH);
}
else {
digitalWrite(TILL_POWER_PIN,LOW);
}
updateServos();

}

void updateServos() {

//analogValue = analogRead(analogPin); // read the analog input
//tillerPulse = (analogValue * 19) / 10 + MINPULSE; // convert the analog value
// to a range between MINPULSE
// and MAXPULSE.

if (dothrottle) {
// tillerPulse the servo again if rhe refresh time (20 ms) have passed:
digitalWrite(THROTT_MAIN_PIN, HIGH);
delayMicroseconds(throttlePulse);
digitalWrite(THROTT_MAIN_PIN, LOW); // Turn the motor on

digitalWrite(THROTT_DIFF_PIN, HIGH);
delayMicroseconds(throttleDiffPulse);
digitalWrite(THROTT_DIFF_PIN, LOW); // Stear Motors
delayMicroseconds(5000 - throttlePulse - throttleDiffPulse);

}
else {
delayMicroseconds(5000);
}
dothrottle = !dothrottle;

digitalWrite(TILL_STBD_PIN, HIGH); // Turn the motor on
digitalWrite(TILL_PORT_PIN, HIGH); // Turn the motor on
delayMicroseconds(tillerPulse); // Length of the pulse sets the motor position
digitalWrite(TILL_STBD_PIN, LOW); // Turn the motor on
digitalWrite(TILL_PORT_PIN, LOW); // Turn the motor on

delayMicroseconds(5000-tillerPulse);

}

« Previous StepDownload PDFView All StepsNext Step »
1 comment
Aug 28, 2009. 5:51 PMJAREDB says:
You could probably mount all of the electronics in a o-ring sealed aluminum housing. You could then heatsink the motor controller to the case.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
12
Followers
2
Author:timothy
Here is a site from when I Lived aboard and cruised in a wooden boat: www.slowtimes.com Current blog of randomness: growdown.blogspot.com I am trying to concentrate my dwindling hobby time only on b...
more »