Robot control using MIT APP inventor

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kirathekiller
Date:
Tue Mar 20 04:30:39 2018 +0000
Commit message:
Remote Controlled Robot

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 20 04:30:39 2018 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+//#include <stdio.h>
+//#include <string.h>
+
+
+
+
+
+DigitalOut m1f(PTC2);
+DigitalOut m1r(PTC3);
+DigitalOut m2f(PTC4);
+DigitalOut m2r(PTC12);
+
+Serial pc(USBTX, USBRX);
+Serial blue(PTC15, PTC14);
+char c=0;
+
+int main()
+{
+    while (true) {
+           
+        if(blue.readable()>0)
+        {
+            c=blue.getc();
+            }
+            if(c=='F')//forward
+            {
+                m1f = 1;
+                m1r = 0;
+                m2f = 1;
+                m2r = 0;
+            }
+        
+        else if(c=='B') //backward
+        //wait(0.2f);
+        {
+            m1f = 0;
+            m1r = 1;
+            m2f = 0;
+            m2r = 1;
+        }
+        else if(c=='L') //left
+        {
+            m1f = 1;
+            m1r = 0;
+            m2f = 0;
+            m2r = 0;
+        }
+        else if(c=='R') //right
+        {
+            m1f = 0;
+            m1r = 0;
+            m2f = 1;
+            m2r = 0;
+        }
+        else if(c=='S') //stop
+        {
+            m1f = 0;
+            m1r = 0;
+            m2f = 0;
+            m2r = 0;
+        }     
+        
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 20 04:30:39 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/aa5281ff4a02
\ No newline at end of file