Basic Alert Function for K64F with Bluetooth

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
varza
Date:
Wed Dec 12 21:57:58 2018 +0000
Commit message:
Alert_Master needed to be combined with Alert_Slave

Changed in this revision

Master_Main_Collision.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 26ab4d6016ae Master_Main_Collision.cpp
--- /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
diff -r 000000000000 -r 26ab4d6016ae mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 12 21:57:58 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file