Jordan Beason
/
A1_Q3_1-3_jbeason
Final Commit
Revision 0:d08b5dcb3f52, committed 2019-10-04
- Comitter:
- jbeason3
- Date:
- Fri Oct 04 21:30:23 2019 +0000
- Commit message:
- Final Commit
Changed in this revision
main.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 d08b5dcb3f52 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 04 21:30:23 2019 +0000 @@ -0,0 +1,70 @@ +#include "mbed.h" +DigitalOut led1(p24); +DigitalOut led2(p23); +DigitalOut led3(p22); +DigitalOut led4(p21); +AnalogIn photo(p15); +AnalogIn LM19(p18); +Serial pc(USBTX, USBRX); + +struct NMEA{ + char header[5]; + char buffer[100]; + char checksum[2]; +}; + +NMEA data; +Timer t; + +int main() { + t.start(); + while(1) { + float light = photo.read(); + float temp = LM19.read(); + float tempC = (1.8663 - 3.3*temp)/0.01169; + //print NMEA string + pc.printf("$TTMPL %f, %f, %f, %f; \r\n", t.read(), temp, tempC, light); + if (tempC < 20 & light > 1.75) { + led1 = 1; + led2 = 0; + led3 = 0; + led4 = 0; + // 3.3 print out + pc.printf("$TTMPL %f, %f, %f, Cold, %f, Day; \r\n", t.read(), temp, tempC, light); + } + if (tempC < 20 & light < 1.75) { + led1 = 0; + led2 = 1; + led3 = 0; + led4 = 0; + // 3.3 print out + pc.printf("$TTMPL %f, %f, %f, Cold, %f, Night; \r\n", t.read(), temp, tempC, light); + } + if (tempC > 20 & light > 1.75) { + led1 = 0; + led2 = 0; + led3 = 1; + led4 = 0; + // 3.3 print out + pc.printf("$TTMPL %f, %f, %f, Hot, %f, Day; \r\n", t.read(), temp, tempC, light); + } + if (tempC > 20 & light < 1.75) { + led1 = 0; + led2 = 0; + led3 = 0; + led4 = 1; + // 3.3 print out + pc.printf("$TTMPL %f, %f, %f, Hot, %f, Night; \r\n", t.read(), temp, tempC, light); + } + wait(5); + + //clean serial ports + while(pc.readable()){ + pc.getc(); + + } + } + } + + +
diff -r 000000000000 -r d08b5dcb3f52 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 04 21:30:23 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file