Safety system for RC car, crash avoidance

Hi

I'm thinking about overriding my brushless ESC on my rc car. Would I be able to do this with the servo library?

Using a HC-SR04 sensor to detect objects and brake the ESC.

Are you already using the servo library to control the ESC ?

If not I think you would have to intercept the R/C signal and get the Arduino to control the ESC. Then the Arduino could also change the ESC signal in response to other inputs.

...R

I havent got that far yet, the idea is only in my head at this point.

My quick solution to this is to use a relay to switch between signal from receiver and signal from arduino.
And from what I understand the servo library outputs a signal which is readable my a ESC since a servo can understand it.

There is a few bumps in the road tho, if the car approaches a hill it will sense this as a obstacle and brake.
But I'm planning to test this system out on a flat asphalt at first.

You can get various servo signal combiners, you might find one that outputs the minimum of
two signals to the output even.

As @Robin2 alluded, one way to do this is to read the signals from the receiver, process them, then output them to the ESC using the Servo library or similar. Whether it's the best way is up for debate; it would certainly be the most flexible, since if you can intercept all the signals from the receiver, it opens up the possibility to record macros for playback, etc.

The low-tech way to do this is by using the PulseIn() function:

https://www.arduino.cc/en/Reference/PulseIn

...however, it's not the best way to go about it - because it is a blocking function (IIRC), and can cause issues if you need to read multiple channels, do more stuff, etc.

There are libraries out there specifically for RC stuff with the Arduino - for instance:

Arduino Radio Control (transmitter)

RCArduino: How To Read an RC Receiver With A Microcontroller - Part 1 (info on reading a receiver - be sure to check out this somewhat convoluted site for more)

ArduinoRCLib download | SourceForge.net (another RC library - I think this one is for both ends, but it hasn't been updated in a long while - so keep that in mind - some hacking will probably be required)

In short - your idea is perfectly feasible, however you ultimately choose to implement it.