Manually ESC dirivng with arduino

Hey aruino lovers:

I asked a few questions before but something just came on my mind;

Ive read post about driving BEC circuits for brushless motors. Many of them says; should use servo lib for driving. Is it posible to driving BECs manually with followng code. Have anyone tried to driving BECs via manuel pwm?

{
  digitalWrite(13, HIGH);
  delayMicroseconds(1100 - 1800); // duty cycle 1.1ms - 1.8ms
  digitalWrite(13, LOW);
  delay(20); // 20ms delay
}

Yes, that will work. I assume that you 1100 - 1800 meant here any value in between those values and not -700. The main problem starts if you want to do something else beside driving your motor in you main loop too. The Servo-library just takes care of the constant updating of the servo (and the ESC in this case).

Korman

thank you sir

I got the main idea of driving esc with servo lib. but i never dealt with the servos before. that look just too hard for me. Im considering brushed motors as well but they have similar problems like providing high amps...

Below is some simple servo test code where you can send different servo position values to the arduino using the serial monitor. Apparently with the ESCs an arming value has to be sent for a period of time first to arm the ESC for operation.

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for 0019 and later

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
      Serial.begin(9600);
        myservo.attach(7);
        Serial.println("servotest-21"); // so I can keep track of what is loaded
        }

void loop() {

        while (Serial.available()) {
        delay(10);  
          if (Serial.available() >0) {
        char c = Serial.read();  //gets one byte from serial buffer
        readString += c;} //makes the string readString
        }
        
      if (readString.length() >0) {
      Serial.println(readString);
      int n;
      char carray[6];
      readString.toCharArray(carray, sizeof(carray));
      n = atoi(carray); 
      myservo.writeMicroseconds(n);
      //myservo.write(n);
      readString="";
      } 
   }