temperature sensor application as a temperature based fan using the FRDM -K64F board

Dependencies:   DHT mbed

Fork of frdm_Grove_PIR_Example by NXP

main.cpp

Committer:
Akshayiupui
Date:
2016-05-07
Revision:
1:5c2fc62b9c0a
Parent:
0:d444f103013a

File content as of revision 1:5c2fc62b9c0a:


 
#include "mbed.h"
#include "DHT.h"
 
DHT sensor(D4, DHT11);
DigitalOut vcc(PTA1);
int main()
{
    int error = 0;
    float h = 0.0f, c = 0.0f, dp = 0.0f, dpf = 0.0f;
 
    while(1) {
        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;}
    }
}