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
- Committer:
- brainliang
- Date:
- 2019-03-16
- Revision:
- 0:d0c188d2cd1c
File content as of revision 0:d0c188d2cd1c:
/*
用普通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);
}
}