void setSpeed(int speed)
{
// speed is from 0 to 100 where 0 is off and 100 is max speed
// the following maps speed values of 0-100 to angles from 0-180
int angle = map(speed, 0, 100, 0, 180);
myservo.write(angle);
The motor has started to move after the ESC is armed.
I would like to know from this code, what does " setSpeed" mean?
Is it by varying the value of setSpeed, the motor will increase or decrease it speed ?
Your picture does not give me a brand name (unless it is SU/E) but that does look like a typical RC hobby ESC.
setSpeed is the name of a function in your code. It has one argument, speed, that it expects to be between 0 and 100. It uses that speed and the servo library to talk to your ESC and tell it how much throttle to feed to the motor.
Yes, by calling the setSpeed function with different values in the speed argument, the motor should change speed accordingly.
Hi MrZd,
The setSpeed function calls the standard servo library commands.
The servo write command tells the servo library to send pulses correlating to the angle given in the parameter.
So (roughly) setSpeed(30); is similar to setting the throttle stick on an RC transmitter to 30%. setSpeed(90); is similar to setting the throttle stick to 90%.
This will arm the typical RC ESC.
I said roughly, because different transmitters have different ranges. And kuxz's code maps the setSpeed speed command to a servo angle range of 0-180 degrees. This is not an exact match to throttle commands. But it appears to work. I suspect that some fiddling with those numbers might be needed to get the ESC to be happy with the arming procedure.