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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:c3fd46448f3e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 11 04:57:13 2018 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+PwmOut mypwm(PA_7);
+
+DigitalOut myled(LED1);
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+int pwm_val = 1;
+
+int main() {
+
+ mypwm.period_ms(10);
+ mypwm.pulsewidth_us(100);
+
+ pc.printf("pwm set to %.2f %%\n", mypwm.read() * 100);
+
+ while(1) {
+ myled = !myled;
+
+ pc.printf("pwm set to %.2f %%\n", mypwm.read() * 100);
+
+ mypwm.pulsewidth_us(pwm_val+=100);
+ if(pwm_val > 10000)
+ {
+ pwm_val = 0;
+ }
+
+ wait(0.001);
+ }
+}