Dependencies:   Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
hankpkai
Date:
Sat Mar 11 23:40:59 2017 +0000
Commit message:

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	Sat Mar 11 23:40:59 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/simon/code/Motor/#f265e441bcd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 11 23:40:59 2017 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "Motor.h"
+
+//DigitalOut led(LED1);
+DigitalIn sw1(p5);
+DigitalIn sw2(p6); 
+BusOut led(LED1,LED2,LED3,LED4);
+Motor m(p21, p11, p12); // pwm, fwd, rev
+
+int main() {
+    led = 0;
+    m.speed(0);
+    int count = 3;
+    float speed = 0;
+    while(1) {
+    
+        if(sw1 == 0 && count < 5)    
+        {   
+            count ++;
+            speed +=0.5;
+            m.speed(speed);
+            if(count == 3)
+                led =0;
+            else if (count == 1)
+                led = 0x1;
+            else if (count == 2)
+                led = 0x2;
+            else if (count == 4)
+                led = 0x4;
+            else if (count == 5)
+                led = 0x8;
+            wait(1);
+            
+        }
+        
+        else if(sw2 == 0 && count>0  )
+        {
+            count --;
+            speed -=0.5;
+            m.speed(speed);
+            if(count == 3)
+                led =0;
+            else if (count == 1)
+                led = 0x1;
+            else if (count == 2)
+                led = 0x2;
+            else if (count == 4)
+                led = 0x4;
+            else if (count == 5)
+                led = 0x8;
+            
+            wait(1);
+        }    
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Mar 11 23:40:59 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file