Code help

I am trying to compose some code to have the arduino read a PWM signal for some data coming from an ESC but Im really confused on how I would create the code could someone please help. Also the Communication protocol from the ESC is attached.

castle_link_live_2_0.pdf (537 KB)

You only have to read the pins repeatedly.
Probe the pin
When the pin goes low, you have nothing special to do
Probe the pin
When the pin goes high, use a variable to remember the time at which it occurs
Probe the pin
When the pin goes low again
Measure the time it took to get there
Process the information

void loop() {
  unsigned long chrono;       //Those 3 variables can also be made global
  unsigned long dataItem;
  byte pinValue ;

  while (digitalRead(pin) == LOW) {}  //wait for the next message
  while (digitalRead(pin) == HIGH) {} //wait for the start of the timed signal
  chrono = micros();  //1 millisecond = 1000 microseconds.
  while (digitalRead(pin) == LOW) {} //Wait for the tick
  dataItem = micros() - chrono;
  
  //Process your data
  
}

Jacques

...which is exactly what the pulseIn() function does, except it does allow for the case when the pulse does not arrive in time. The version above will be stuck forever for most faults such as a wire getting disconnected.

Note to squid: I'm not going to download a PDF to look at code. Post it inline with [ code ] tags. If it's too big to fit then try to trim it down to the smallest working program which demonstrates the fault.

The pdf doesnt have code in it, its a document from the ESC manufactor on how to read the signal using a microcontroller or similar hardware