bbb

Dependencies:   m3pi mbed

Fork of Serial by Ling Ye

Revision:
0:48d48099e20c
Child:
1:a95f56d5e053
--- /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");
+    }
+          
+}