temperature sensor application as a temperature based fan using the FRDM -K64F board
Fork of frdm_Grove_PIR_Example by
Revision 1:5c2fc62b9c0a, committed 2016-05-07
- Comitter:
- Akshayiupui
- Date:
- Sat May 07 01:27:48 2016 +0000
- Parent:
- 0:d444f103013a
- Commit message:
- Temperature sensor application as an temperature based fan control with the help of FRDM-K64F board.
Changed in this revision
DHT.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d444f103013a -r 5c2fc62b9c0a DHT.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Sat May 07 01:27:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Wimpie/code/DHT/#9b5b3200688f
diff -r d444f103013a -r 5c2fc62b9c0a main.cpp --- a/main.cpp Thu Dec 31 23:29:45 2015 +0000 +++ b/main.cpp Sat May 07 01:27:48 2016 +0000 @@ -1,25 +1,28 @@ + #include "mbed.h" - -InterruptIn motion(D2); - -int motion_detected = 0; - -void irq_handler(void) +#include "DHT.h" + +DHT sensor(D4, DHT11); +DigitalOut vcc(PTA1); +int main() { - motion_detected = 1; -} - -int main(void) -{ - int cnt = 0; - motion.rise(&irq_handler); - + int error = 0; + float h = 0.0f, c = 0.0f, dp = 0.0f, dpf = 0.0f; + while(1) { - if(motion_detected) { - cnt++; - motion_detected = 0; - printf("Hello! I've detected %d times since reset\n", cnt); - } + wait(2.0f); + error = sensor.readData(); + if (0 == error) { + c = sensor.ReadTemperature(CELCIUS); + dp = sensor.CalcdewPoint(c, h); + dpf = sensor.CalcdewPointFast(c, h); + printf("Temperature in Celcius: %4.2f\n", c); + } else { + printf("Error: %d\n", error); + } while((int)c > 30){vcc=!vcc;} + while((int)c<30 ){vcc=0;} } } + + \ No newline at end of file