simple PWM

Revision:
0:b166a4d08fd6
--- /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;
+      }
+   }
+}