Simon Ford
/
PwmIn_HelloWorld
A Hello World example to use PwmIn to read a PWM input signals
main.cpp@0:f52f1e22f72d, 2010-09-02 (annotated)
- Committer:
- simon
- Date:
- Thu Sep 02 18:20:01 2010 +0000
- Revision:
- 0:f52f1e22f72d
Example using the PwmIn published as a library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:f52f1e22f72d | 1 | // Example using PwmIn interface library, sford |
simon | 0:f52f1e22f72d | 2 | // - Note: uses InterruptIn, so not available on p19/p20 |
simon | 0:f52f1e22f72d | 3 | |
simon | 0:f52f1e22f72d | 4 | #include "mbed.h" |
simon | 0:f52f1e22f72d | 5 | #include "PwmIn.h" |
simon | 0:f52f1e22f72d | 6 | |
simon | 0:f52f1e22f72d | 7 | PwmOut x(p21); |
simon | 0:f52f1e22f72d | 8 | PwmOut y(p22); |
simon | 0:f52f1e22f72d | 9 | |
simon | 0:f52f1e22f72d | 10 | PwmIn a(p5); |
simon | 0:f52f1e22f72d | 11 | PwmIn b(p6); |
simon | 0:f52f1e22f72d | 12 | |
simon | 0:f52f1e22f72d | 13 | int main() { |
simon | 0:f52f1e22f72d | 14 | x = 0.5; |
simon | 0:f52f1e22f72d | 15 | y = 0.2; |
simon | 0:f52f1e22f72d | 16 | while(1) { |
simon | 0:f52f1e22f72d | 17 | printf("a: pw = %f, period = %f\n", a.pulsewidth(), a.period()); |
simon | 0:f52f1e22f72d | 18 | printf("b: pw = %f, period = %f\n", b.pulsewidth(), b.period()); |
simon | 0:f52f1e22f72d | 19 | wait(2); |
simon | 0:f52f1e22f72d | 20 | } |
simon | 0:f52f1e22f72d | 21 | } |