use servo motor with "for"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Ryuga
Date:
Sat Apr 06 09:35:44 2019 +0000
Commit message:
create; ; thi is new program to use servo-motor for irst-year student

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	Sat Apr 06 09:35:44 2019 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+
+PwmOut servo(D10);
+
+int main() {
+    servo.period(0.020);
+    while(1) {
+        for(float offset = 0.0f; offset < 0.001f; offset += 0.0001f){
+            servo.pulsewidth(0.001f + offset);
+            wait(0.25);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 06 09:35:44 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file