Board Garudago >> Motor6 --> 1 || Motor2 --> 2 key board: A S --> control pwm1 K L --> control pwm2

Dependencies:   Motor mbed

Board Garudago (Motor6 ==> 1 || Motor2 ==> 2)

key board

  • A S : control pwm1
  • K L : control pwm2

Files at this revision

API Documentation at this revision

Comitter:
Fathoni17
Date:
Thu Nov 10 13:19:25 2016 +0000
Commit message:
Board Garudago (Motor6 --> 1 || Motor2 --> 2); key board A --> pwm1++; S --> pwm1--;; key board K --> pwm2++; L --> pwm2--;;

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
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/Motor.lib	Thu Nov 10 13:19:25 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/Motor/#c75b234558af
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 10 13:19:25 2016 +0000
@@ -0,0 +1,48 @@
+// Library
+#include "mbed.h"
+#include "Motor.h"
+
+// Deklarasi pin
+Motor motor1 (PB_9, PA_12, PC_5);
+Motor motor2 (PA_11, PA_6, PC_6);
+
+int main (void){
+    Serial pc(USBTX,USBRX);
+    pc.baud(9600);
+    pc.readable();
+    float pwm1=0.1;
+    float pwm2=0.1;
+    
+    while(1){
+        char val = pc.getc();
+        switch (val) {
+            case 'a' :{
+                pwm1 = pwm1+0.05;
+            }
+            break; 
+            case 's' :{
+                pwm1 = pwm1-0.05;
+            }
+            break;
+            case 'k' :{
+                pwm2 = pwm2+0.05;
+            }
+            break;
+            case 'l' :{
+                pwm2 = pwm2-0.05;
+            }
+            break;
+        }
+        if (pwm1 <= 0.1){ 
+            pwm1 = 0.1;
+        }
+        if (pwm2 <= 0.1){ 
+            pwm2 = 0.1; 
+        }
+        
+        motor1.speed(pwm1);
+        motor2.speed(pwm2);
+        wait_ms(5);
+        pc.printf ("pwm1 = %.5f      pwm2 = %.5f\n", pwm1, pwm2);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 10 13:19:25 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file