Continuos operation of a motor

Hi Guys,

I am trying to operate a brushless motor LOSI 10250KV with a Dragon X 30A speed controller from my arduino uno. I implemented a for loop to control the speed of the motor after reading an analogue input from a potentiometer but the motor only only works for around 11seconds and then stops before picking up again. The ideal situation I intend is to have the speed of the motor controlled mainly by the turning of the potentiometer

Would you be able to suggest an alternative configuration of the loop statement here please

void loop()

sensorValue = analogRead(sensorPin); //read the value
sensorValue = map(sensorValue, 0, 1023, 0, 255);
for (sensorValue = 0; sensorValue <= 255; sensorValue +=5)
{analogWrite(ESCpin1, sensorValue);
analogWrite(ESCpin2, sensorValue);
//analogWrite(ESCpin3, sensorValue);
//analogWrite(ESCpin4, sensorValue);
delay (100);


You're reading a sensorValue, mapping it to some range, then setting it to zero and using the variable to control a loop.
What did you intend to do?

Please please use code tags.

What is the for statement for? why have it all?


Guys, I'm new to arduino programming, not really clear on the complexities. I intend to control the speed of rotation of the motors which the electronic speed controllers are connected to.

Mark, not sure about code tags

Thanks for the responses, still need your help though

Would you be able to suggest an alternative configuration of the loop statement here please

The FOR loop is utterly pointless there and the 'alternative configuration' I suggest is to delete it. The loop() function is called repeatedly and you should put in it the code you want to run each time it is called i.e. read the sensor input, convert that to the required motor speed and instruct the motor to run at that speed.

I don't have a Dragon X 30A speed controller but it looks as if it is designed to be used in RC systems in which case the control signal it expects is likely to be a standard 50Hz servo control signal and not a PWM signal as produced by analogWrite(). The Servo library makes it easy to generate the standard servo control signal.

Hi, when you post your sketch, post the complete sketch including setup and any lines before it.
Also do TOOLS then Autoformat in the IDE to format your sketch.
The # button on the menu above this box will help you present you code properly.

Tom..Hope to help..... :slight_smile: