Any code not works for me

Motor: Rocket F540 V2 4370KV
ESC: Readytosky Waterproof 60A(https://www.aliexpress.com/item/Readytosky-Waterproof-60A-Brushless-ESC-Electric-Speed-Controller-with-5-5V-3A-BEC-for-1-10/32864211143.html)

#include <Servo.h>
#define MAX_SIGNAL 2000
#define MIN_SIGNAL 700
#define MOTOR_PIN 9
int value = 0;

Servo motor;

void setup() {
  Serial.begin(9600);
  Serial.println("START");
  Serial.println("ESC is calibrating");

  motor.attach(MOTOR_PIN);
  motor.writeMicroseconds(MAX_SIGNAL);
  
  while (!Serial.available());
  Serial.read();
  motor.writeMicroseconds(MIN_SIGNAL);
  Serial.println("ESC calibrated");
  Serial.println("Speed: ");

}

void loop() {  
    value = Serial.read();
    motor.writeMicroseconds(value);

}

and motor does not move

Look at one of the examples that come with the library.

void loop() { 
    value = Serial.read();
    motor.writeMicroseconds(value);
}

You are reading from the serial input buffer even if there is no data available so most of the values returned are -1. To see how to read a number from Serial, reliably, see example #4 of the serial input basics tutorial. To change a number that is received as text to a number that can be used with servo.write, use the atoi() function.

#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 700
#define MOTOR_PIN A0

int value = 0;

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;

Servo motor;

void setup() {
  Serial.begin(9600);
  Serial.println("START");
  Serial.println("ESC is calibrating");

  motor.attach(MOTOR_PIN);
  motor.writeMicroseconds(MAX_SIGNAL);
  motor.writeMicroseconds(MIN_SIGNAL);
  
  Serial.println("ESC calibrated");
  Serial.println("Speed: ");
}

void loop() { 
    recvWithEndMarker();

    value = atoi(receivedChars);
    motor.writeMicroseconds(value);

    Serial.println(value);
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    if (Serial.available() > 0) {
        rc = Serial.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

still motor not started

Try this code and post the serial monitor output, please.

#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 700
#define MOTOR_PIN A0

int value = 0;

const byte numChars = 32;
char receivedChars[numChars];

boolean newData = false;

Servo motor;

void setup()
{
   Serial.begin(9600);
   Serial.println("START");
   Serial.println("ESC is calibrating");

   motor.attach(MOTOR_PIN);
   motor.writeMicroseconds(MAX_SIGNAL);
   motor.writeMicroseconds(MIN_SIGNAL);

   Serial.println("ESC calibrated");
   Serial.println("Speed: ");
}

void loop()
{
   recvWithEndMarker();
   if(newData == true)
   {
   Serial.print("received characters  ");
   Serial.println(receivedChars);
   value = atoi(receivedChars);
   motor.writeMicroseconds(value);
   Serial.print("converted value  ");
   Serial.println(value);
   newData = false;
   }
}

void recvWithEndMarker()
{
   static byte ndx = 0;
   char endMarker = '\n';
   char rc;

   if (Serial.available() > 0)
   {
      rc = Serial.read();

      if (rc != endMarker)
      {
         receivedChars[ndx] = rc;
         ndx++;
         if (ndx >= numChars)
         {
            ndx = numChars - 1;
         }
      }
      else
      {
         receivedChars[ndx] = '\0'; // terminate the string
         ndx = 0;
         newData = true;
      }
   }
}

Make sure that line endings is set to newline in serial monitor.

line ending.jpg

sth is maybe wrong or idk ... motor running after time ... 1 min or more and he stops after that ... and running again after seconds and stops again and not running anymore

unfortunately, nothing is happening right now :confused: yt
i want only left .. right and braking

Are you sure that you are performing a proper ESC arming sequence?

No now i'm not sure... I tested many code and anyone not works

1500 is minimum... 1600 = start

Do you have a manual for the ESC? I searched but can't find one.

Rekimo:
sth is maybe wrong or idk ... motor running after time ... 1 min or more and he stops after that ... and running again after seconds and stops again and not running anymore

How is everything powered? That sounds like a bad battery or one that needs charging.

And your arming sequence looks more like a way of putting the ESC into programming mode,which is not what you want. What sounds do you hear from the ESC/motor?

Can you try it out using the Knob example program to see what values it really does respond to?

Steve


Only this:

Battery: zippy compact 2200mah 3s 25c lipo pack

Steve asked a few questions.

slipstick:
How is everything powered? That sounds like a bad battery or one that needs charging.

And your arming sequence looks more like a way of putting the ESC into programming mode,which is not what you want. What sounds do you hear from the ESC/motor?

Can you try it out using the Knob example program to see what values it really does respond to?

Steve

You replied with information about the battery, Steve's first question. The next 2 questions appear to have been ignored.

What sounds do you hear from the ESC/Motor?

Can you try it out using the Knob example program to see what values it really does respond to?

Battery: 12.70V

Sounds: YT(yesterday was different .. like this beep beep and after calibration like this from YT)
YT: - YouTube

Knob: yeah .. when i buy some potentiometers(yep i don't have any...)

ok wait the minute ... not potentiometer .. but i have this

It looks like you are using a servo tester to feed the signal to the ESC and getting the motor to run. Good!
It also looks like you are printing some value to the serial monitor.

I do not know what value you are printing. It does not appear to have any correlation to what you are doing with the servo tester. How is the arduino involved with this experiment using the servo tester?

It would be interesting to have the arduino read the value that the servo tester is sending. Look in to how to read an EC receiver. If you were to print that value to the serial monitor and then use the servo tester to successfully arm and run the motor, then you could use those same values to do so from the arduino.