Hauptprogramm

Dependencies:   ILI9340_Driver_Lib PM2_Libary Lib_DFPlayerMini

Revision:
20:f825e91784fe
Parent:
19:9ccd591cb637
Child:
22:f71d32309307
--- a/Servo/servo_bewegung.cpp	Thu Apr 22 14:43:14 2021 +0000
+++ b/Servo/servo_bewegung.cpp	Thu Apr 22 15:57:47 2021 +0000
@@ -11,18 +11,28 @@
 #define TIME         100
 
 
-void bewegung(int zeit){ 
-
-Servo servo1(PA_0);
-servo1.Enable(1500,20000);
-    for(int j=0; j<zeit; j++){
-       for (int pos = 1000; pos < 2000; pos += 25) {
-          servo1.SetPosition(pos);
-          wait_ns(STEP);
-      }
-      for (int pos = 2000; pos > 1000; pos -= 25) {
-          servo1.SetPosition(pos);
-          wait_ns(STEP);
-      }
-      }
+void bewegung(){
+    Servo servo1(PA_0);
+    servo1.Enable(1000,20000);
+    
+    //Servo Bewegung
+    for (int pos = 1000; pos > 800; pos -= 25) {
+        servo1.SetPosition(pos);
+        thread_sleep_for(STEP);
+    }
+    for(int j=0; j<2; j++){
+        for (int pos = 800; pos < 1200; pos += 25) {
+            servo1.SetPosition(pos);
+            thread_sleep_for(STEP);
+        }
+        for (int pos = 1200; pos > 800; pos -= 25) {
+            servo1.SetPosition(pos);
+            thread_sleep_for(STEP);
+        }
+    }
+    for (int pos = 800; pos < 1000; pos += 25) {
+        servo1.SetPosition(pos);
+        thread_sleep_for(STEP);
+    }
+    servo1.Disable();
 }