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.
Diff: main.cpp
- Revision:
- 0:d0c188d2cd1c
diff -r 000000000000 -r d0c188d2cd1c main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Mar 16 01:58:24 2019 +0000
@@ -0,0 +1,21 @@
+/*
+用普通IO模拟输出PWM
+*/
+
+#include "mbed.h"
+#include "IO_pwm.h"
+
+DigitalOut my_led(PC_13);
+IO_pwm my_pwm(PA_5); // IO used by pwm_io function
+int main() {
+
+ my_pwm.pwm_io(20000, 0.075); // 20ms - 25%,舵机控制周期20ms占空比范围0.025--0.125
+
+ while(1) {
+ my_pwm.pwm_io(20000, 0.025); // 20ms - 2.5%
+ my_led = !my_led;
+ wait(0.5);
+ my_pwm.pwm_io(20000, 0.125); // 20ms - 12.5%
+ wait(0.5);
+ }
+}
\ No newline at end of file