Hi everyone...So I got this reversable ESC. Using it to run a Brushless motor. Would like to use the motor in a washing machine like contraption that spins back and forth and cleans parts in water. Thus the motor should move forward and backward.
Here is the issue: When I use a potentiometer the mid-value of 90 makes the motor standstill, while values above make it move forward and number below backward. With the following code, everything works as expected, but as soon as I type in values the motor does not reverse. Actually, it does not change direction unless I use a potentiometer.
I don't see a reason why a value from (0-180) from the Potentiometer reverses the motor's direction just fine, but when I type in the values it does not change direction.
Code that works fine with Potentiometer and reverses the direction:
In the pot version You loop on and on sending the mapped pot value.
I guess that in the typed, manual version You need to perform that ESC.write over and over during that second.
Make a functioin that loops for a second ESC.writing the value sent to the function. Call that function instead of doing ESC.write.
WOW! Thank you this tottally worked. The ESC does need a constant stream of values being sent to work. I will have to figure out how to clean up this code, but this is great start. Here is code is used to quickly test the theory:
Great! Read my previous reply again. You can do the same using much less of code. Call this function from Your test for loops instead of the ESCwrite.
function kickESP(int val){ //val is the value sent to the ESP
unsigned long time = millis();// register the starting time of the one second timing.
while( millis() < time + 1000){
ESP.write(val);
delay(1);
}
}