Boleh bisa langsung dicoba, tap servo base belum dikalibrasi

Dependencies:   mbed Servo

Revision:
2:34ed8b55eba6
Parent:
1:9284c57e84da
Child:
3:d1860dee0552
--- a/main.cpp	Sat Apr 13 18:51:43 2019 +0000
+++ b/main.cpp	Sat Apr 13 19:29:51 2019 +0000
@@ -8,37 +8,26 @@
   21 22
     1 */
     
-Servo servo21(PA_7);
-Servo servo22(PB_6);
+Servo servo1(PA_7);
+Servo servo2(PB_6);
 Serial pc(D1, D0);
 
-void servo2(float f, float g){
-    servo21.write(f);
-    servo22.write(g);
-    pc.printf("%f", servo21.read());
-    pc.printf("\n");
-    pc.printf("%f", servo22.read());
-    pc.printf("\n");
-}
-
 int main() {
     pc.baud(9600);
     pc.printf("test begin\n");
     
     //tes
-    servo21.calibrate(0.001,150);
-    servo22.calibrate(0.001,150);
-    servo21.write(0);
-    servo22.write(1.0);
+    servo1.calibrate(0.001,150);
+    servo1.write(0);
+    servo2.write(1.0);
     while(1){
-        float m=0.0;
+        pc.printf("input (1..10) bakal dijadiin persen : ");
         float n=0.0;
-        pc.scanf("%f",&m);
-        pc.printf("test \n");
         pc.scanf("%f",&n);
-        pc.printf("test \n");
-        float f = m;
-        float g = n;
-        servo2(f,g);
+        pc.printf("\n");
+        //float f = (float)n/(float)10;
+        servo1.write(f);
+        pc.printf("%f", servo1.read());
+        pc.printf("\n");
     }
 }