for textbook v4.4

Dependencies:   mbed DHT11

Committer:
HeptaSatTraining2019
Date:
Wed Nov 06 18:09:06 2019 +0000
Revision:
0:d743365e4ee4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HeptaSatTraining2019 0:d743365e4ee4 1 #include "mbed.h"
HeptaSatTraining2019 0:d743365e4ee4 2 #include "Dht11.h"
HeptaSatTraining2019 0:d743365e4ee4 3
HeptaSatTraining2019 0:d743365e4ee4 4 Serial pc(USBTX, USBRX);
HeptaSatTraining2019 0:d743365e4ee4 5 Dht11 sensor(p15);
HeptaSatTraining2019 0:d743365e4ee4 6 int temp,humid;
HeptaSatTraining2019 0:d743365e4ee4 7
HeptaSatTraining2019 0:d743365e4ee4 8 int main() {
HeptaSatTraining2019 0:d743365e4ee4 9 while(1){
HeptaSatTraining2019 0:d743365e4ee4 10 sensor.read();
HeptaSatTraining2019 0:d743365e4ee4 11 temp = sensor.getFahrenheit();
HeptaSatTraining2019 0:d743365e4ee4 12 humid = sensor.getHumidity();
HeptaSatTraining2019 0:d743365e4ee4 13 temp = (temp - 32.0)/1.80; // Fahrenheit --> Celsius
HeptaSatTraining2019 0:d743365e4ee4 14 pc.printf("T: %d, H: %d\r\n", temp, humid);
HeptaSatTraining2019 0:d743365e4ee4 15 wait(1.0);
HeptaSatTraining2019 0:d743365e4ee4 16 }
HeptaSatTraining2019 0:d743365e4ee4 17 }