A sketch for controlling a brushless motor

Hi all

I'm trying to controll the speed of a brushless motor conncted to ECS without using a transmittor ( setting the brushless motor to run at a certin speed when turned on )

What is a good sketch to do so?

Most ESCs are controlled like servos, so start there.

lg, couka

Servo library in other words. You'll need to figure out a reliable arming sequence for your particular motor.

MarkT:
Servo library in other words. You'll need to figure out a reliable arming sequence for your particular motor.

I'm new to Arduino coding

I've created this code to run the motor

#include <Servo.h>

Servo motor;

void setup() {

motor.attach(9);

}

void loop() {
motor.writeMicroseconds(1500);
delay(2000);
motor.writeMicroseconds(2000);

}

where 1500 = neutral throttle = no movment
2000 = max throttle = forward movment

is it possible for the throttle to be controlled by a rotary encoder feedback ? like if I want the throttle to be 1800 for a distance of 2 meters and then go back to neutral throttle after the 2 meter?

inabhani:
is it possible for the throttle to be controlled by a rotary encoder feedback ? like if I want the throttle to be 1800 for a distance of 2 meters and then go back to neutral throttle after the 2 meter?

Yes!, that's the best thing about Arduino, microcontrollers or any cpu for that matter. It will do what you program it to.

A rotary encoder is very simple to interface with an Arduino, you can very easily write code to take the number of pulses and convert to a distance with some calibration. If you are just starting you won't find this too tricky, there are lots of rotary encoder examples.

It's when you want to start traveling a certain speed or stop at a certain distance is when the complexity goes up. There are volumes of books written about control theory and the PID loop.

The Arduino community is vast and you will find library's and examples for all kinds of sensors and control methods on these forums.