![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Basic Alert Function for K64F with Bluetooth
Master_Main_Collision.cpp
- Committer:
- varza
- Date:
- 2018-12-12
- Revision:
- 0:26ab4d6016ae
File content as of revision 0:26ab4d6016ae:
#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; } } }