Venkata Arza
/
master_tempHumid
master for temp/humid k64f
Revision 0:94c04881e58a, committed 2018-12-12
- Comitter:
- varza
- Date:
- Wed Dec 12 22:04:21 2018 +0000
- Commit message:
- master for temp k64f;
Changed in this revision
Master_Main_Temp.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Master_Main_Temp.cpp Wed Dec 12 22:04:21 2018 +0000 @@ -0,0 +1,85 @@ +#include "mbed.h" +Timeout response; + +DigitalOut LED3a(D4); +DigitalOut LED2a(D5); +DigitalOut green(LED_GREEN); +DigitalOut red(LED_RED); +DigitalIn sw2(SW2); +Serial pc(USBTX, USBRX ); +Serial blue(PTC15, PTC14); //tx, rx + + + +int main() +{ + char hold = 'b'; + char send = 'Z'; + pc.baud(9600); + blue.baud(9600); + printf("Master connecting to the slave\n"); + int flagt = 0; + int farenh; + int dew; + + while (true) { + blue.putc(send); + wait(0.5f); // wait a small period of time + // printf("\n waiting \n\r"); + if(blue.readable())//Determine if there is a character available to read. + { + + //--------------------------Temperature Module----------------------------- + // printf("\n entering \n\r"); + + hold = blue.getc(); + farenh = hold - '0'; + + wait(0.5f); + + hold = blue.getc(); + dew = hold - '0'; + + + //--------------------------Temperature Module End---------------------------- + + //----------------------------------------------------------------------------- + + printf("\nTemperature = %iF \n\rDewpoint = %i\n\r", farenh, dew); + + } + + + wait(0.5f); // wait a small period of time + green = !green; // toggle a led + if(farenh <= 70) { + flagt = -1; + printf("Home Heat Triggered. \n\r"); + } + if (farenh >= 77){ + printf("Home Cooling Triggered. \n\r"); + flagt = 1; + } + else { + flagt = 0; + } + + if(flagt == 1) + { + for(int count = 0; count < 2; count++) + { + wait(0.5f); + LED3a = !LED3a; + } + } + else if(flagt == -1) + { + for(int count = 0; count < 2; count++) + { + wait(0.5f); + LED2a = !LED2a; + } + } + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 12 22:04:21 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file