Bletooth

Dependencies:   mbed

Revision:
0:1f7823a82513
diff -r 000000000000 -r 1f7823a82513 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 09 14:36:24 2017 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+Serial bt(D10,D2); //RX TX
+Serial pc(USBTX, USBRX);
+DigitalOut dcm01(D6);
+DigitalOut dcm02(D7);
+DigitalOut dcm03(D4);
+DigitalOut dcm04(D5);
+char x;
+
+
+
+
+int main()
+{
+    
+    bt.baud(9600);
+
+    while(1) {
+        if (bt.readable()) {
+            x=  bt.putc(bt.getc());
+
+
+            if ( x == 'a') {
+
+                dcm01 = 1;
+                dcm02 = 0;
+                dcm03 = 1;
+                dcm04 = 0;
+
+            }
+
+            if (x == 'b') {
+
+                dcm01 = 0;
+                dcm02 = 1;
+                dcm03 = 0;
+                dcm04 = 1;
+
+            }
+
+            if (x== 'c') {
+
+                dcm01 = 1;
+                dcm02 = 0;
+                dcm03 = 0;
+                dcm04 = 1;
+            }
+            if (x== 'd') {
+
+                dcm01 = 0;
+                dcm02 = 1;
+                dcm03 = 1;
+                dcm04 = 0;
+            }
+            if (x== 'e') {
+
+                dcm01 = 0;
+                dcm02 = 0;
+                dcm03 = 0;
+                dcm04 = 0;
+            }
+
+
+        }//chiusa if (bt.readable())
+
+    }//Chiusa while
+}//Chiusa main
+