![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Sample for Servomoter (used by LPC1768)
Dependencies: mbed
main.cpp
- Committer:
- mikawataru
- Date:
- 2016-10-24
- Revision:
- 0:6c4856d10c9f
File content as of revision 0:6c4856d10c9f:
//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