Motor omni

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
rahmadirizki18
Date:
Thu Sep 22 15:16:37 2016 +0000
Parent:
0:7bbc230e00d6
Commit message:
motor1

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
diff -r 7bbc230e00d6 -r 91e3b7b265fd main.cpp
--- a/main.cpp	Tue Nov 23 16:19:19 2010 +0000
+++ b/main.cpp	Thu Sep 22 15:16:37 2016 +0000
@@ -3,11 +3,138 @@
 #include "mbed.h"
 #include "Motor.h"
 
-Motor m(p23, p6, p5); // pwm, fwd, rev
+Motor m1(PA_9, PC_2, PC_3); // pwm, fwd, rev
+Motor m2(PA_8, PB_0, PC_15); // pwm, fwd, rev
+Motor m3(PA_11, PA_6, PA_5); // pwm, fwd, rev
+Motor m4(PA_10, PB_5, PB_4); // pwm, fwd, rev
+
 
 int main() {
+/*    float keterangan = -1.0;
+    float fade = 0.01; */
+    char perintah;
+    
+    Serial pc(USBTX,USBRX);
+    Serial data(PA_0,PA_1); // tx,rx
+    
+    data.baud(115200);
+    pc.baud(9600);
+    while (1) {    
+       
+    if (data.readable()){
+        perintah = data.getc();
+        pc.printf("%c\n",perintah);
+        
+    
+    switch (perintah){
+        case '8' : 
+            //Maju
+            
+            m1.speed(0.7);
+            m2.speed(-0.7);
+            m3.speed(-0.7);
+            m4.speed(0.7);
+            pc.printf("Maju"); 
+            break;
+        case '2' : 
+            //Mundur
+            m1.speed(-0.7);
+            m2.speed(0.7);
+            m3.speed(0.7);
+            m4.speed(-0.7); 
+            pc.printf("Mundur");
+            break;
+        case '4' : 
+            //Kiri
+            m1.speed(-0.7);
+            m2.speed(-0.7);
+            m3.speed(0.7);
+            m4.speed(0.7); 
+            pc.printf("Kiri");
+            break;
+        case '6' :
+            //Kanan 
+            m1.speed(0.7);
+            m2.speed(0.7);
+            m3.speed(-0.7);
+            m4.speed(-0.7);
+            pc.printf("Kanan"); 
+            break;
+        case 'E' :
+            //Searah Jarum Jam 
+            m1.speed(0.7);
+            m2.speed(0.7);
+            m3.speed(0.7);
+            m4.speed(0.7);
+            pc.printf("Putar Kanan"); 
+            break;
+        case 'Q' :
+            //Berlawanan Jarum Jam
+            m1.speed(-0.7);
+            m2.speed(-0.7);
+            m3.speed(-0.7);
+            m4.speed(-0.7); 
+            pc.printf("Putar Kiri");
+            break;
+        default  :
+            //Keadaan OFF
+            m1.speed(0);
+            m2.speed(0);
+            m3.speed(0);
+            m4.speed(0); 
+       }
+        }else {
+            m1.speed(0);
+            m2.speed(0);
+            m3.speed(0);
+            m4.speed(0); }
+       
+       
+        }
+        
+}            
+
+/*    
+     //Maju   
+    if ( perintah == 'W') {
+        m1.speed(0.5);
+        wait (5);
+        m1.speed(0);
+        pc.printf("Maju");
+        
+        }       
+     //Mundur
+    if ( perintah == 'S') {
+        m1.speed(-0.5);
+        wait (5);
+        m1.speed(0);
+        pc.printf("Mundur");
+        }       
+        
+     //Kiri
+     
+     
+     //Kanan   
+  
+  */
+  
+  
+      /*  m1.speed(keterangan);
+        keterangan = keterangan +fade;
+        if (keterangan > 1.00 || keterangan <-1.00) {
+             fade = -fade;
+            
+            }
+              
+        wait (0.1);
+        }
+
+*/
+/*    
     for (float s= -1.0; s < 1.0 ; s += 0.01) {
-       m.speed(s); 
+       m1.speed(s); 
        wait(0.02);
     }
-}
+  */  
+    
+    
diff -r 7bbc230e00d6 -r 91e3b7b265fd mbed.bld
--- a/mbed.bld	Tue Nov 23 16:19:19 2010 +0000
+++ b/mbed.bld	Thu Sep 22 15:16:37 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file