Hey folks,
i have a Hobbyking 80A SBEC ESC and I don't know why the motor doesn't react after initializing the ESC and pressing the deadmen switch for security reasons. Have I the wrong values for that?
Btw I am using a analog stick for controlling the ESC with lowest value of 18 and the center value is 796 and 1023 as the highest.
Greetings
Mainsedora
#include "ESC.h"
#define SPEED_MIN (1000) // Set the Minimum Speed in microseconds
#define SPEED_MAX (2000) // Set the Minimum Speed in microseconds
ESC myESC (2, SPEED_MIN, SPEED_MAX, 500); // ESC_Name (ESC PIN, Minimum Value, Maximum Value, Default Speed, Arm Value)
int oESC, deadmen = 1, cruiseButton, pot = A0, val, curval = 1000; // Variable for the speed sent to the ESC
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT); // LED Visual Output
pinMode(pot, INPUT);
pinMode(deadmen, INPUT);
myESC.arm(); // Send the Arm value so the ESC will be ready to take commands
digitalWrite(LED_BUILTIN, HIGH); // LED High Once Armed
delay (5000); // Wait for a while
Serial.println("init finished");
}
void loop() {
val = analogRead(pot); //read potentiometer value
Serial.println(val, DEC);
val = map(val, 800, 1023, 1000, 2000); //map potentiomater value (0-1024 to 1000-2000 micro seconds);
if (digitalRead(deadmen) == LOW) { //check if deadman switch is pressed
if (digitalRead(cruiseButton) == HIGH) { //check if cruise button is pressed, if it is dont modify the curval
// do nothing to curval
} else if (curval < val) { //check if curval is less than potentiometers mapped value
curval = curval + 5; // if it is less, add 5 to the curval
} else if (curval > val) { //check if curval is more than potentiometers mapped value
curval = curval - 5; //if it is more, remove 5 from the curval
}
} else if (curval > 1000) { //if deadmans switch isnt turned and curval is more than 1000ms (throttle down value)
curval = curval - 5; //remove 5 from curval to start slowing down if above condition is true
}
myESC.speed(curval); //write microseconds to esc
delay(50); //delay the loop 50ms
}