ESC Quadcopter

I have been working on a quadcopter controlled by ESC’s and a 2.4GHz transmitter. I have made good headyway, but I am unable to control the ESC’s with the Arduino. I use the Servo Library’s writeMicroseconds() function, yet I am still getting an irregular signal error. I have attached my short code. Any help would be appreciated!

quad.ino (2.13 KB)

I didn’t get a chance to look at the code much but the problem may be pulseIn() causing issues with interrupts and the servo library. Maybe a pin change interrupt would be better to use than pulseIn().

Put your code in code tags, more eyes will see it then.

pulseIn is a blocking function, you don't want any blocking functions anywhere in a flight-control system!

Definitely using an ISR to record the pulse transition times is a better approach - then they can be read by any other part of the code whenever (suitably guarded with a critical section of course, which only has to wait a few us at worst).