Used to read incoming PWM signals from RC channels
Diff: PulseIn.h
- Revision:
- 0:1a57c7f88422
- Child:
- 1:eaf70ff4df07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PulseIn.h Wed Dec 19 08:06:23 2012 +0000 @@ -0,0 +1,21 @@ +#ifndef RC_CHANNEL_H +#define PULSEIN_H + +#include "mbed.h" + +class PulseIn +{ + public: + PulseIn(PinName p); + int read(); // read the last measured data + + private: + InterruptIn _k; // interrupt on the pin to react when signal falls or rises + void rise(); // start the time measurement when signal rises + void fall(); // stop the time mesurement and save the value when signal falls + Timer t; // timer to measure the up time of the signal and if the signal timed out + int _duration; // last measurement data +}; + +#endif +