Arduino NANO Simple E-boat Controller (Forward, Neutral, Reverse) Fixed Speed

by jbrandonms in Circuits > Arduino

176 Views, 0 Favorites, 0 Comments

Arduino NANO Simple E-boat Controller (Forward, Neutral, Reverse) Fixed Speed

IMG_9523.JPG
IMG_9533.JPG
cover SW.png

Simple controller for Brushless Motor with ESC and Arduino for docking a Sail Boat.

Switch to control Forward/Neutral/Reverse

Switch to control the throttle by 3 positions.

Ignition Key Switch to turn on the controller.

Supplies

IMG_9526.JPG
IMG_9527.JPG
IMG_9529.JPG
IMG_9531.JPG
IMG_9532.JPG
IMG_9276.JPG

Arduino Nano x1

1P2T Paddle switch F/N/R x1

1P2T Paddle switch simple x1

1KOhm Resistor x4

ESC Acording to the motor size that you will use.

Brushless Motor

Ignition Key Switch

WaterProof or Regular Connectors

Heat Shrink Tubing

Controller Box

48V Li-ion Battery

5VDC Regulator (48VDC to 5VDC)

Wires ESC to Motor

Wires ESC to Battery

The Code

code2.png


#include <Servo.h>



Servo myservo;

int switch1 = 6;

int switch2 = 4;

int switch3 = 9;

int switch4 = 8;

int speed1 = 1400;

int speed2 = 1370;

int speed3 = 1300;

int speed4 = 1600;

int speed5 = 1680;

int speed6 = 1800;

int stop = 1500;


float potVal;

float MaxDialVal;

float pwmVal;

float MaxpwmVal;

int nIts = 20;


int LowVolt = 227 + 180;

int HiVolt = 929 - 180;


void setup() {

myservo.attach(3);

pinMode(switch1, INPUT_PULLUP);

pinMode(switch2, INPUT_PULLUP);

pinMode(switch3, INPUT_PULLUP);

pinMode(switch4, INPUT_PULLUP);

Serial.begin(9600);

myservo.writeMicroseconds(1500); // send "stop" signal to ESC. Also necessary to arm the ESC.


}

void loop() {

int switch1value = digitalRead(switch1);

int switch2value = digitalRead(switch2);

int switch3value = digitalRead(switch3);

int switch4value = digitalRead(switch4);



if (switch1value == LOW && switch2value == LOW) {

myservo.write(stop);

Serial.println("Current Speed: Neutral");




}

else if (switch1value == LOW && switch2value == HIGH) {

if (switch3value == LOW && switch4value == HIGH) {


//


for (int i = 0; i < nIts; i++) {


    potVal = potVal;

}

potVal = potVal / nIts;


pwmVal = map(potVal, LowVolt, HiVolt, 1100, 2000); // maps potentiometer values to PWM value.


    MaxpwmVal = 1500 + (500 * (MaxDialVal / 1058));


//

myservo.writeMicroseconds(speed1);

Serial.println("Current Speed: Reverse 1");

}

else if (switch3value == LOW && switch4value == LOW) {

myservo.writeMicroseconds(speed2);

Serial.println("Current Speed: Reverse 2");

}

else if (switch3value == HIGH && switch4value == LOW) {

myservo.writeMicroseconds(speed3);

Serial.println("Current Speed: Reverse 3");

}

}

else if (switch1value == HIGH && switch2value == LOW) {

if (switch3value == LOW && switch4value == HIGH) {

myservo.writeMicroseconds(speed4);

Serial.println("Current Speed: Forward 1");

}

else if (switch3value == LOW && switch4value == LOW) {

myservo.writeMicroseconds(speed5);

Serial.println("Current Speed: Forward 2");

}

else if (switch3value == HIGH && switch4value == LOW) {

myservo.writeMicroseconds(speed6);

Serial.println("Current Speed: Forward 3");

}

}

}








Downloads

The Wiring

IMG_9506.JPG
IMG_9511.JPG
IMG_9521.JPG
IMG_9291.JPG
FZWIEBOLDN3Y72U.jpg
FMD48JPLDN3Y72R.jpg
F94KEPQLDN3Y721.jpg

Check Joystick version for further info, the only difference is that the port A0 for the joystick will be replaced by inputs from a switch on D8 and D9.


Joystick version HERE


The BOX

IMG_9508.JPG
IMG_9509.JPG
IMG_9510.JPG
IMG_9511.JPG
IMG_9512.JPG
IMG_9514.JPG
IMG_9519.JPG
IMG_9520.JPG
IMG_9524.JPG

//Crafting/////Loading////////......

Test It

E-Boat controller (arduino, Esc and switches)
F8KO87LLDN3Y6EX.png