Basic Master connection code. (Bluetooth)

Dependencies:   mbed

Revision:
0:8a61e3541a5e
Child:
1:c573caf40864
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 19 12:40:15 2018 +0000
@@ -0,0 +1,108 @@
+#include "mbed.h"
+
+//DigitalIn trigger(p22);
+//DigitalOut transmit(p28);
+
+DigitalIn tl(p17); //change to correct board
+DigitalIn tr(p18);
+DigitalIn bl(p19);
+DigitalIn br(p20);
+
+Serial device(p28,p27);  //tx,rx
+
+BusOut myleds(LED4, LED3, LED2, LED1);
+
+int buffer[4];
+int temp1;
+
+int row;
+int columns;
+
+char array[4];
+int i;
+
+void Array();
+
+int main()
+{
+
+    myleds = 0;
+
+    device.baud(19200);
+    buffer[0] = 1;
+    buffer[1] = 0;
+    buffer[2] = 1;
+    buffer[3] = 0;
+//    buffer[4] = 0;
+//    buffer[5] = 0;
+//    buffer[6] = 1;
+//    buffer[7] = 0;
+
+    array[0] = 0;
+    array[1] = 0;
+    array[2] = 0;
+    array[3] = 0;
+
+    while(1) {
+
+        if (tl > 0) {
+            myleds = 1;
+        } else {
+            myleds = 0;
+        }
+
+        Array();
+        device.putc(1);
+        for (int i=0; i<5; i++) {
+
+            //device.printf("%i",buffer[i]);
+
+            //device.putc(buffer[i]);
+            device.putc(array[i]);
+        }
+        //wait(1);
+    }
+
+}
+
+void Array()
+{
+    for(i=0; i<=1 ; i=i+1) {
+        if (i == 0) {
+            if (tl > 0) {
+                array[0] = 1;
+            } else {
+                array[0] = 0;
+            }
+        } else if (i == 1) {
+            if (tr > 0) {
+                array[1] = 1;
+            } else {
+                array[1] = 0;
+            }
+        }
+    }
+    for(i=0; i<=1 ; i=i+1) {
+        if (i == 0) {
+            if (bl > 0) {
+                array[2] = 1;
+            } else {
+                array[2] = 0;
+            }
+        } else if (i == 1) {
+            if (br > 0) {
+                array[3] = 1;
+            } else {
+                array[3] = 0;
+            }
+        }
+    }
+    /*
+    for (row=0; row<2; row++) {
+        for(columns=0; columns<2; columns++) {
+            printf("%d     ", array[row][columns]);
+        }
+        printf("\n");
+    }*/
+    //printf("\n");
+}