ESC with brushed motor

i have tried out the ESC with a brushed motor with the code shown below.

#include <Servo.h>

Servo myservo;

void arm()
{
//arm speed controller, modify as necessary for your ESC

Serial.println("Arming");
setSpeed(30);
delay(2000);

setSpeed(90);
delay(2000);

Serial.println("Armed");
setSpeed(30);
delay(2000);

}

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);

}

void setup()
{

Serial.begin(115200);
myservo.attach(9);
arm();

}

void loop()
{
int speed;

Serial.println("Sweeping up");
for(speed = 37; speed <= 90; speed+= 1)
{

setSpeed(speed);
Serial.println(speed);
delay(100);

}

setSpeed(30);
delay(1000);

Serial.println("Sweeping down");
for(speed = 90; speed >37; speed -=1)
{

setSpeed(speed);
Serial.println(speed);
delay(100);

}

Serial.println("30 halting...");
setSpeed(30);
delay(5000);

}

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 ?

I am currently using the ESC shown below.

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.

Below is the link from the supplier of the ESC and the motor.

http://www.gwsus.com/english/product/speedcontroller/100.htm

Hi people.

I don't really get it how to "arm" ESC by just setting Setspeed(). I thought we have to send pulses to arm it.

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.

Below is the link from the supplier of the ESC and the motor.

ICS100 & GS100

Hmmm......

GWS's picture does not look anything like the picture you posted earlier.

this is from the supplier . I thinkthe specification is the same?

Thanks vinceherman =) I can control it now. =)