Sample for Servomoter (used by LPC1768)
Dependencies: mbed
Revision 0:6c4856d10c9f, committed 2016-10-24
- Comitter:
- mikawataru
- Date:
- Mon Oct 24 17:00:55 2016 +0000
- Commit message:
- Sample for Servomoter
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 6c4856d10c9f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 24 17:00:55 2016 +0000 @@ -0,0 +1,27 @@ +//Servo test01 +// Servo basic test + +#include "mbed.h" + + +#define ON +#define OFF 0 + +PwmOut servo1(p23); + +int main() { + float pwidth; + servo1.period_ms(20);// pulse cycle = 20ms + + while(1){ + for(pwidth=0.001; pwidth<=0.003; pwidth+=0.000001) { // 1ms ~ 2ms + servo1.pulsewidth(pwidth); // pulse servo out + wait(0.001);} + + for(pwidth=0.003; pwidth>=0.001; pwidth-=0.000001) { // 1ms ~ 2ms + servo1.pulsewidth(pwidth); // pulse servo out + wait(0.001); + + } + }//while +}//main4 \ No newline at end of file
diff -r 000000000000 -r 6c4856d10c9f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Oct 24 17:00:55 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file