![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
mbed PWM DCservo
Revision 0:7b5e6b979e90, committed 2016-10-20
- Comitter:
- rkuo2000
- Date:
- Thu Oct 20 12:38:53 2016 +0000
- Commit message:
- mbed PWM DCservo
Changed in this revision
diff -r 000000000000 -r 7b5e6b979e90 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Oct 20 12:38:53 2016 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r 7b5e6b979e90 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 20 12:38:53 2016 +0000 @@ -0,0 +1,18 @@ +// using NuMaker-PFM-NUC472 PWM1 output to drive DC servo motor +#include "mbed.h" + +PwmOut pwm1(PF_10); // PWM1 pinname + +int main() { + + int i=0; + printf("...DCserv Start...\n\r"); + pwm1.period_us(20000); // set PWM period to 20ms (50Hz) + + for (i=500; i<=2500; i=i+200) { // from 0.5ms to 2.5ms + pwm1.pulsewidth_us(i); // set PWM pulse width to rotate motor + Thread::wait(1000); // delay + printf("DCservo pulse width = %d\n\r", i); + } + printf("...DCserv End.....\n\r"); +}
diff -r 000000000000 -r 7b5e6b979e90 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Oct 20 12:38:53 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#a6f3fd1a60d5df59246d7caf3f108c4d34e1808e