Arduino NANO Simple E-boat Controller (Forward, Neutral, Reverse) Fixed Speed
by jbrandonms in Circuits > Arduino
187 Views, 0 Favorites, 0 Comments
Arduino NANO Simple E-boat Controller (Forward, Neutral, Reverse) Fixed Speed



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






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

#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







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









//Crafting/////Loading////////......
Test It
)
