bbb

Dependencies:   m3pi mbed

Files at this revision

API Documentation at this revision

Comitter:
lingye96
Date:
Tue Nov 01 03:54:17 2016 +0000
Child:
1:a95f56d5e053
Commit message:
Serial

Changed in this revision

m3pi.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/m3pi.lib	Tue Nov 01 03:54:17 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/m3pi/#4b7d6ea9b35b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 01 03:54:17 2016 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "m3pi.h"
+
+m3pi m3pi;
+Serial pc(USBTX,USCRX);
+
+int main() {
+
+
+    m3pi.locate(0,1);
+    m3pi.printf("Serial Control");
+    pc.printf("Press 'WASD' to control the m3pi\n");
+    
+    while (1)
+    {
+        wait (2.0);
+        char input = pc.getc();
+        if(input=='w')
+        {
+            m3pi.forward(0.5); // Forward half speed
+            wait (0.5);        // wait half a second
+        }
+        else if (input=='a')
+        {
+            m3pi.left(0.5);    // Turn left at half speed
+            wait (0.5);        // wait half a second
+        }
+        else if (input=='s')
+        }
+            m3pi.backward(0.5);// Backward at half speed 
+            wait (0.5);        // wait half a second
+        }
+        else if (input=='d')
+        {
+            m3pi.right(0.5);   // Turn right at half speed
+            wait (0.5);        // wait half a second
+        }
+        else
+        {
+            pc.printf("Try again and press 'WASD' to control the m3pi\n"); 
+        }
+        m3pi.printf("Complete");
+    }
+          
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 01 03:54:17 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0
\ No newline at end of file