I am attempting to control a DC brushless motor using an ESC I purchased from Amazon. However, I am encountering difficulties with initializing the ESC. While the ESC emits a series of beeps, it does not respond to any input. Occasionally, I hear the melody typically played when the ESC is connected to my RC cars, but it quickly reverts to continuous beeping with no control over the DC motor.
Below is the code I am currently running, as well as the setup I am using. Any guidance or suggestions to resolve this issue would be greatly appreciated.
#include <Servo.h>
Servo esc; // Create a Servo object to control the ESC
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
esc.attach(9); // Attach the ESC to digital pin 9
esc.writeMicroseconds(1000); // Initialize the ESC with a 1000us signal
delay(1000); // Wait for the ESC to initialize
}
void loop() {
if (Serial.available() > 0) { // Check if data is available to read
int speed = Serial.parseInt(); // Read the incoming integer
if (speed >= 0 && speed <= 180) { // Ensure the speed is within the valid range
esc.write(speed); // Set the ESC speed
Serial.print("Speed set to: ");
Serial.println(speed);
delay(3000);
} else {
Serial.println("Invalid speed. Enter a value between 0 and 180.");
}
}
}

