![](/media/cache/profiles/7810ccd41bf26faaa2c4e1f20db70a71.50x50_q85.png)
A test program for the PWMAverage library. This program will print the average duty cycle of a signal (1Hz-100kHz) after a button is pressed for a few seconds.
Revision 0:a84599c324fb, committed 2012-08-29
- Comitter:
- p07gbar
- Date:
- Wed Aug 29 11:51:28 2012 +0000
- Commit message:
- Initial commit - Working
Changed in this revision
diff -r 000000000000 -r a84599c324fb PWMAverage.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWMAverage.lib Wed Aug 29 11:51:28 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/p07gbar/code/PWMAverage/#449ea283d634
diff -r 000000000000 -r a84599c324fb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 29 11:51:28 2012 +0000 @@ -0,0 +1,33 @@ +// Measure and print the average duty cycle of a signal connected to p29 and p30 (together) while the button (p16) is pulled high + +#include "mbed.h" +#include "PWMAverage.h" + +DigitalOut myled(LED1); + +PWMAverage pa(p29,p30); + +DigitalIn button (p16); + +Timer tmr; + +int main() +{ + button.mode(PullDown); + while(1) + { + pa.reset(); + + while (!button) {} + pa.start(); + tmr.start(); + myled=1; + + while (button) {} + pa.stop(); + tmr.stop(); + myled=0; + + printf("Average dudy cycle over %d us was %.4f\n\r",tmr.read_us(),pa.read()); + } +} \ No newline at end of file
diff -r 000000000000 -r a84599c324fb mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 29 11:51:28 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file