Arduino achieve simple manipulation of ESC
principle:
ESC is needed is a pwm signal, we can put it simply interpreted as a square wave
and I use the new ESC west of (time point, but can also use)
need is 1ms ~ 2ms / 20ms square wave signal
1ms 0 throttle
2ms is full throttle
Connected to the power transfer
1) the motor is electrically connected to any line transfer three thick, no order
2) three thin line signal terminal, brown (dark spot color) a negative electrode, a positive electrode red, yellow pwm signal terminal
3) connected battery (do not reverse, otherwise burn out, do not short-circuit, or explosion)
after connecting the battery alert tone will become louder, sharper
The first method, custom square wave
void setup(){
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop(){
int analog = analogRead(A0);//A0处接了一个旋钮,读取值
Serial.println(analog);
pulse(analog);//调用脉冲函数
}
void pulse(int analog){
analog = map(analog,0,1025,1000,2000);//A0输入的范围为(0~1024)
digitalWrite(13,HIGH);//将13作为信号输出端
delayMicroseconds(analog);//这个延迟时间单位为微秒
digitalWrite(13,LOW);
delayMicroseconds(20000-analog);
}
//注意一定要先调到最大(满油门)再调到最小(0油门),此为初始化
The second method, using the built-in servo library functions
#include<Servo.h>
Servo myservo;
void setup(){
Serial.begin(9600);
myservo.attach(9);//注意这次信号输出要接在~9端,
}
void loop(){
int analog = analogRead(A0);
pulse(analog);
}
void pulse(int analog){
analog = map(analog,0,1020,1000,2000);//1000为0度,2000为180度
Serial.println(analog);//打印油门大小
myservo.writeMicroseconds(analog);//使用write也可以,不过不稳定
}
//注意一定要先调到最大(满油门)再调到最小(0油门),此为初始化