Basic Master connection code. (Bluetooth)

Dependencies:   mbed

Revision:
2:25cede572d19
Parent:
1:c573caf40864
--- a/main.cpp	Mon Feb 19 13:09:13 2018 +0000
+++ b/main.cpp	Fri May 25 18:08:42 2018 +0000
@@ -1,142 +1,18 @@
 #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];
-char matrix[2][2];
-int i;
-int j;
-
-void Array();
-void Matrix();
+Serial rn42(p9,p10); //TX, RX
+Serial pc(USBTX, USBRX);
 
 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;
+    
+    rn42.baud(460800);
+    //baud rate defined
+    wait(0.5);
 
     while(1) {
 
-        if (tl > 0) {
-            myleds = 1;
-        } else {
-            myleds = 0;
-        }
 
-        //Array();
-
-        Matrix();
-
-        device.putc(1);
-        for (int i=0; i<2; i++) {
-            for (int j=0; j<2; j++) {
-
-                //device.printf("%i",buffer[i]);
-
-                //device.putc(buffer[i]);
-                device.putc(matrix[i][j]);
-            }
-        }
-        //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");
-}
-
-void Matrix()
-{
-
-    if (tl > 0) {
-        matrix[0][0] = 1;
-    } else {
-        matrix[0][0] = 0;
-    }
-    if (tr > 0) {
-        matrix[0][1] = 1;
-    } else {
-        matrix[0][1] = 0;
-    }
-    if (bl > 0) {
-        matrix[1][0] = 1;
-    } else {
-        matrix[1][0] = 0;
-    }
-    if (br > 0) {
-        matrix[1][1] = 1;
-    } else {
-        matrix[1][1] = 0;
-    }
-
-}