autonomous car and motor goes full reverse after wrong initialization of ESC?

Hi, I have a problem with my robotics project. I am building an autonomous car using a LiPo battery (2S) and a 15T motor and an Arduino board. I know that I have to initialize the ESC at the beginning of my code but for some reason, the initialization goes wrong sometimes. I don’t know if my code is wrong or what. Sometimes the initialization is fine and I’m able to run the car, but sometimes it goes full reverse which is very inconvenient. These are the 8 lines of code I have to initiate the ESC:


My small knowledge of these motors is that swapping any two wires will reverse the direction of rotation.


What is "throttle"? And why are you using digital writes on the same pin (?) as "throttle" - instead of using your "throttle" object?

Please post your entire set of code. Also a link to the manual of the ESC (or a picture or something of the manual) - so we can see what the arming procedure actually is.