Basic Alert Function for K64F with Bluetooth

Dependencies:   mbed

Revision:
0:26ab4d6016ae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Master_Main_Collision.cpp	Wed Dec 12 21:57:58 2018 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+Timeout response;
+
+DigitalOut green(LED_GREEN);
+DigitalOut red(LED_RED);
+DigitalOut led(D6); 
+DigitalIn  sw2(SW2);
+Serial pc(USBTX, USBRX );
+Serial blue(PTC15, PTC14); //tx, rx
+
+int main()
+{
+    int flag = 0; 
+    char hold = 'b';
+    char recieved; 
+    char send = 'Z';
+    pc.baud(9600);
+    blue.baud(9600);
+    printf("Master connecting to the slave\n");
+
+    while (true) {
+
+        blue.putc(send);
+        wait(0.5f); // wait a small period of time       
+
+        if(blue.readable())//Determine if there is a character available to read.
+        {
+               
+               //--------------------------Temperature Module-----------------------------
+               
+
+                recieved = blue.getc();
+                //printf("\n word = %c \n\r", recieved);
+                int RANGE = ((recieved) - '0');
+                float RANGEFIXED = RANGE; 
+
+                
+                //--------------------------Temperature Module End----------------------------
+                
+                
+                pc.printf("\n Lock Mode: unknown person(s) within = %f Units  \n\r", RANGEFIXED);  
+                if(RANGEFIXED < 49)
+                {
+                     pc.printf("\nAlert Triggered\n\r");  
+                     flag = 1; 
+             
+                }    
+                else   
+                {
+                    pc.printf("\n All Clear \n\r"); 
+                    flag = 0; 
+                }
+                    
+        }
+        
+        if(flag == 1)
+            for(int timer = 0; timer < 10; timer++)
+            {
+                wait(0.05f); 
+                led = !led;
+            }
+                
+    }
+
+}
\ No newline at end of file