Controlling 60 A ESC. New Coder please help

Hello community,

I am having difficulty programming my Arduino MEGA 2560 to control the PWM signal sent to my ESC to control my 770Kv motor. So far I have been using serial monitor and commanding different PWM values but after I command a certain value, the PWM returns to 0 and the throttle is not sustained, I have tried building an array of all commanded PWM values and if the serial signal is not available the code would refer back to the most recent PWM value and send it to the ESC but that was not a reliable method. Any help would be greatly appreciated. The current code is below.

#include <Servo.h>
Servo ESC;

void setup()
ESC.attach(9,1000,2000); //PWM Pin Connection Port on Arduino
ESC.write(0); //Activates ESC
delay(5000); //Wait time before commanding throttle values

void loop()
while(Serial.available() > 0)
int val = Serial.parseInt(); //reads integer vals from serial monitor input
Serial.println(val); //Print throttle value
ESC.write(val); //Write throttle value to ESC

"770 kv motor."

Is that 770,000 volt motor ?

No that is simply a rating associated with this motor. It has to do with voltage and rpm. # of volts given to the motor * Kv rating = theoretical motor RPM.

My guess is that you have Serial Monitor set to "Newline". Try changing it to "No line ending".


Simple servo test code that might work with your ESC assuming it accepts servo type control pulses.

// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

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

void setup() {

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c =;  //gets one byte from serial buffer
      readString += c; //makes the string readString

  if (readString.length() >0) {
    int n = readString.toInt();