RC Autonomous Car Build - ESC control

Hi,
I’m working on an autonomous RC car with 3 Arduinos which are connected to ultrasonic sensors, servo and ESC separately.

Everything works perfectly fine except for the ESC. It refuses to arm itself or work at any value other than 1600 (which is too slow), which I am really confused about. I want the value to start from 1700 in my distance remapping, but the ESC wouldn’t respond to it.
Any help would be appreciated.
Code is pasted below…

#include <Servo.h>
#include<Wire.h>
#include<I2C_Anything.h>

const byte MY_ADDRESS = 43;

Servo myesc;

void setup()
{
  Wire.begin(MY_ADDRESS);
  Serial.begin(9600);
  Wire.onReceive(receiveEvent);
  myesc.attach(10, 500, 2500);
}

 volatile bool haveData = false;
 volatile long distance1, distanceA;
 volatile long distance2, distanceB;
 
 void loop (){

 distanceA = map(distance1, 10, 90, 1600, 1800);
 distanceB = map(distance2, 10, 90, 1600, 1800);

 if(distance1<distance2)
  {myesc.write(distanceA);
 delay(2000);
  myesc.write(1700);}
 else
 {myesc.write(distanceB);
  delay(2000);
  myesc.write(1700);} 


 if(haveData)
 {Serial.print ("Received D1 = ");
  Serial.println (distance1);
  Serial.print ("Received D2 = ");
  Serial.println (distance2);
  haveData = false;}

}

void receiveEvent (int howMany)
{
  if(howMany >= (sizeof distance1) + (sizeof distance2))
{
  I2C_readAnything(distance1);
  I2C_readAnything(distance2);
  haveData = false;
}}

What ESC is it? Does it have reverse or is it forward only?

I can't see any code in there that is even attempting to arm the ESC. You just attach it and then write some value to it.

Why not write a simple test program with just the ESC in and see if it really is initialising and how it reacts to a range of values? Or even use the Servo/Knob example from the IDE.

BTW since you are actually writing microseconds not angles to the ESC it's tidier to use the writeMicroseconds() function directly. It saves the servo code from having to check the values and then internally decide to use writeMicroseconds() itself.

Steve

Hi Steve, Thanks a lot for the reply. The ESC somehow works without arming, I didn't realize it needs to be armed, I'm just a beginner lol. I will look into that right now. The ESC is a generic Chinese one I borrowed from someone, and have no way of knowing what ESC that is. It has no name or sticker on it. If there are other ways to identify it, please let me know. It has both forward and reverse. It does initialize when the speed is set to 1600.

Can you please also tell me how an ESC is armed?

Hi, Have you googled arming an esc

Tom... :)