Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // Measure and print the average duty cycle of a signal connected to p29 and p30 (together) while the button (p16) is pulled high 00002 00003 #include "mbed.h" 00004 #include "PWMAverage.h" 00005 00006 DigitalOut myled(LED1); 00007 00008 PWMAverage pa(p29,p30); 00009 00010 DigitalIn button (p16); 00011 00012 Timer tmr; 00013 00014 int main() 00015 { 00016 button.mode(PullDown); 00017 while(1) 00018 { 00019 pa.reset(); 00020 00021 while (!button) {} 00022 pa.start(); 00023 tmr.start(); 00024 myled=1; 00025 00026 while (button) {} 00027 pa.stop(); 00028 tmr.stop(); 00029 myled=0; 00030 00031 printf("Average dudy cycle over %d us was %.4f\n\r",tmr.read_us(),pa.read()); 00032 } 00033 }
Generated on Tue Jul 12 2022 18:56:03 by
