Nuvoton
/
NuMaker-mbed-PWM1_DCservo
NuMaker PWM1 drive +5V DC servo motor
Revision 12:c7ca6b6c7fbc, committed 2021-02-25
- Comitter:
- SHLIU1@OANBE02333.nuvoton.com
- Date:
- Thu Feb 25 11:24:43 2021 +0800
- Parent:
- 11:9772684c13d1
- Commit message:
- Support the both V5.X and V6.X for mbed-os
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Apr 18 16:57:19 2018 +0800 +++ b/main.cpp Thu Feb 25 11:24:43 2021 +0800 @@ -8,11 +8,18 @@ int i=0; printf("...DCserv Start...\n\r"); +#ifdef MBED_MAJOR_VERSION + printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); +#endif 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 +#if MBED_MAJOR_VERSION >= 6 + ThisThread::sleep_for(1000); +#else Thread::wait(1000); // delay +#endif printf("DCservo pulse width = %d\n\r", i); } printf("...DCserv End.....\n\r");