Sample for Servomoter (used by LPC1768)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

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
--- /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
--- /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