A Hello World example to use PwmIn to read a PWM input signals

Dependencies:   mbed PwmIn

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Example using PwmIn interface library, sford
00002 //  - Note: uses InterruptIn, so not available on p19/p20
00003 
00004 #include "mbed.h"
00005 #include "PwmIn.h"
00006 
00007 PwmOut x(p21);
00008 PwmOut y(p22);
00009 
00010 PwmIn a(p5);
00011 PwmIn b(p6);
00012 
00013 int main() {
00014     x = 0.5;
00015     y = 0.2;
00016     while(1) {
00017         printf("a: pw = %f, period = %f\n", a.pulsewidth(), a.period());
00018         printf("b: pw = %f, period = %f\n", b.pulsewidth(), b.period());
00019         wait(2);
00020     }
00021 }