V1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
bernardusrendy
Date:
Tue Apr 16 12:54:03 2019 +0000
Parent:
0:96a0fbdff740
Commit message:
hhhhh

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 96a0fbdff740 -r ed6ad03b86e4 main.cpp
--- a/main.cpp	Mon Feb 18 12:54:07 2019 +0000
+++ b/main.cpp	Tue Apr 16 12:54:03 2019 +0000
@@ -5,10 +5,10 @@
 joysticknucleo joystick(PA_0,PA_1);
 Serial pc(USBTX,USBRX);
 /* Deklarasi Motor Base */
-Motor motorDepan(PB_7, PC_3, PC_0); //(PB_9, PA_12, PC_5); 
-Motor motorKanan(PB_3, PA_10, PC_4);
-Motor motorKiri  (PB_9, PA_6, PA_12);
-int case_joy;
+Motor motorDepan(PB_8, PC_6, PC_5); //(PB_9, PA_12, PC_5); 
+Motor motorBelakang(PB_9, PA_12, PA_6);
+//Motor motorKiri  (PB_9, PA_6, PA_12);
+
 /****************************************************/
 /*         Deklarasi Fungsi dan Procedure           */
 /****************************************************/
@@ -38,10 +38,10 @@
         caseJoystick = 3;
     }
     else if ((!joystick.R1)&&(!joystick.L1)&&(!joystick.atas)&&(!joystick.bawah)&&(!joystick.kanan)&&(joystick.kiri))  {  
-        // Pivot Kiri
+        // Pivot 
         caseJoystick = 4;
     }
-    else if ((!joystick.R1)&&(!joystick.L1)&&(!joystick.atas)&&(joystick.bawah)&&(!joystick.kanan)&&(!joystick.kiri))  {  
+    else if ((!joystick.R1)&&(!joystick.L1)&&(!joystick.atas)&&(!joystick.bawah)&&(!joystick.kanan)&&(!joystick.kiri))  {  
         // Pivot Kiri
         caseJoystick = 5;
     }
@@ -49,69 +49,46 @@
         // Pivot Kiri
         caseJoystick = 6;
     }
-	    
     return(caseJoystick);
 }
 
-void aktuator()
+void aktuator(int case_joy)
 {
     switch (case_joy) {
         case (1): 
         {       
             // Pivot Kanan
-			motorDepan.speed(0.23);
-			motorKanan.speed(0.17);
-			motorKiri.speed(0.23);
+			motorDepan.speed(0.2);
+			motorBelakang.speed(-0.2);
             break;
         }
         case (2): 
         {
             // Pivot Kiri
-			motorDepan.speed(-0.23);
-			motorKanan.speed(-0.17);
-			motorKiri.speed(-0.23);
+			motorDepan.speed(-0.2);
+			motorBelakang.speed(0.2);
             break;
         }
         case (3): 
         {
             // Maju
-			motorDepan.speed(0);
-			motorKanan.speed(-0.17);
-			motorKiri.speed(0.3);
+			motorDepan.speed(0.2);
+			motorBelakang.speed(0.2);
             break;
         }
         case (4): 
         {
-            // Kiri
-			motorDepan.speed(-0.23);
-			motorKanan.speed(0.17);
-			motorKiri.speed(0.3);
-            break;
-        }
-        case (5): 
-        {
-            //Belakang
-			motorDepan.speed(0);
-			motorKanan.speed(0.17);
-			motorKiri.speed(-0.3);
-            break;
-        }
-        case (6): 
-        {
-            // Kanan
-			motorDepan.speed(0.23);
-			motorKanan.speed(-0.17);
-			motorKiri.speed(-0.3);
+            // Mundur
+			motorDepan.speed(-0.2);
+			motorBelakang.speed(-0.2);
             break;
         }
 		default : 
         {
-            motorDepan.brake(1);
-            motorKanan.brake(1);
-            motorKiri.brake(1);
+            break;
         }
 	}
-}
+}  
 /*********************************************************/
 /*                  Main Function                        */
 /*********************************************************/
@@ -122,6 +99,7 @@
     joystick.setup();
     pc.baud(115200);
     wait_ms(1000);
+    int case_joy;
 //    startMillis();
     while(1)
     {   
@@ -136,7 +114,7 @@
             // Masuk ke case joystick
             case_joy = case_joystick();
             //pc.printf("%d\n",case_joy);
-            aktuator();
+            aktuator(case_joy);
         }
         else
         {