ARM mbed Bluetooth Remote Car

Dependencies:   HC_SR04_Ultrasonic_Library mbed

Android App source code and wiring: https://github.com/macdidi5/ARMmbedTurtleCar

Files at this revision

API Documentation at this revision

Comitter:
macdidi5
Date:
Wed Apr 22 04:40:03 2015 +0000
Commit message:
ARM mbed Bluetooth Remote Car

Changed in this revision

HC_SR04_Ultrasonic_Library.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
diff -r 000000000000 -r a57144f199bb HC_SR04_Ultrasonic_Library.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HC_SR04_Ultrasonic_Library.lib	Wed Apr 22 04:40:03 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ejteb/code/HC_SR04_Ultrasonic_Library/#e0f9c9fb4cf3
diff -r 000000000000 -r a57144f199bb main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 22 04:40:03 2015 +0000
@@ -0,0 +1,80 @@
+#include "mbed.h"
+#include "ultrasonic.h"
+
+DigitalOut dcm01(PTD1);
+DigitalOut dcm02(PTD3);
+DigitalOut dcm03(PTD2);
+DigitalOut dcm04(PTD0);
+
+#if   defined(TARGET_LPC1768)
+Serial blue(p9, p10);   // TX, RX
+#elif defined(TARGET_KL25Z)
+Serial blue(PTE0, PTE1);   // TX, RX
+#endif
+
+void dist(int distance)
+{   
+    blue.printf("%d\r\n", distance);
+}
+
+ultrasonic mu(PTD4, PTA4, 0.5, 1, &dist);
+
+int main() {
+    
+    mu.startUpdates();
+    
+    dcm01 = 0;
+    dcm02 = 0;
+    dcm03 = 0;
+    dcm04 = 0;
+    
+    blue.baud(115200);
+    
+    while(1) {
+        if (blue.readable()) 
+        {
+            char command = blue.getc();
+            
+            switch (command) 
+            {
+                // forward
+                case 'F':
+                    dcm01 = 1;
+                    dcm02 = 0;
+                    dcm03 = 1;
+                    dcm04 = 0;
+                    break;
+                // backward
+                case 'B':
+                    dcm01 = 0;
+                    dcm02 = 1;
+                    dcm03 = 0;
+                    dcm04 = 1;
+                    break;
+                // LEFT
+                case 'L':
+                    dcm01 = 1;
+                    dcm02 = 0;
+                    dcm03 = 0;
+                    dcm04 = 1;
+                    break;
+                // right
+                case 'R':
+                    dcm01 = 0;
+                    dcm02 = 1;
+                    dcm03 = 1;
+                    dcm04 = 0;
+                    break;
+                // stop
+                case 'S':
+                    dcm01 = 0;
+                    dcm02 = 0;
+                    dcm03 = 0;
+                    dcm04 = 0;
+                    break;
+            }
+        }
+        
+        mu.checkDistance();
+    }
+}
diff -r 000000000000 -r a57144f199bb mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 22 04:40:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file