John Fitzpatrick
/
PWM_01
simple PWM
Revision 0:b166a4d08fd6, committed 2021-02-10
- Comitter:
- fitzpatrick
- Date:
- Wed Feb 10 02:45:37 2021 +0000
- Commit message:
- initial
Changed in this revision
PWM.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r b166a4d08fd6 PWM.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWM.cpp Wed Feb 10 02:45:37 2021 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +//PWM output channel +PwmOut PWM1(A5); + +Serial pc(USBTX, USBRX); // Serial Port 115200 + +int main() +{ + pc.baud(115200); // Serial Port 115200 + PWM1.period_ms(20); + int x; + x=1; + while(1) + { + PWM1.pulsewidth_ms(x); + x=x+1; + pc.printf("x = %d \r\n",x); + wait(.5); + if(x==10) + { + x=1; + } + } +}
diff -r 000000000000 -r b166a4d08fd6 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Feb 10 02:45:37 2021 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#485bdeee150e2bc8ed75e27d936060fb63a7a7d1