EXP11

Dependencies:   DHT11 TextLCD mbed

Committer:
rx5
Date:
Wed Apr 13 06:28:20 2016 +0000
Revision:
0:78a7d5cdbf61
EXP10

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rx5 0:78a7d5cdbf61 1
rx5 0:78a7d5cdbf61 2 #include "mbed.h"
rx5 0:78a7d5cdbf61 3 #include "Dht11.h"
rx5 0:78a7d5cdbf61 4 #include "TextLCD.h"
rx5 0:78a7d5cdbf61 5
rx5 0:78a7d5cdbf61 6 TextLCD lcd(D2, D3, D4, D5, D6, D7); // Initlize LCD PIN => RS, EN, Data4, Data5, Data6, Data7
rx5 0:78a7d5cdbf61 7 Dht11 mydht11(D9);
rx5 0:78a7d5cdbf61 8 int main(void) {
rx5 0:78a7d5cdbf61 9
rx5 0:78a7d5cdbf61 10 lcd.cls(); // Clear LCD
rx5 0:78a7d5cdbf61 11 lcd.locate(0,0); // cursor on Col=0, Raw=0
rx5 0:78a7d5cdbf61 12 lcd.printf("Experiment - 10"); // print startup message on LCD first Raw
rx5 0:78a7d5cdbf61 13 lcd.locate(0,1); // cursor on Col=0, Raw=1
rx5 0:78a7d5cdbf61 14 lcd.printf("DHT11 with LCD"); // print startup message on LCD second Raw
rx5 0:78a7d5cdbf61 15 wait(3.0); // wait 3 second to show startup message
rx5 0:78a7d5cdbf61 16 while (true) {
rx5 0:78a7d5cdbf61 17 float t,h;
rx5 0:78a7d5cdbf61 18 mydht11.read(); // Read DHT11 sensor
rx5 0:78a7d5cdbf61 19 t = mydht11.getCelsius(); // get Temperature in C
rx5 0:78a7d5cdbf61 20 h = mydht11.getHumidity(); // get Humidity in %
rx5 0:78a7d5cdbf61 21 lcd.cls(); // Clear LCD
rx5 0:78a7d5cdbf61 22 lcd.locate(0,0); // cursor on Col=0, Raw=0
rx5 0:78a7d5cdbf61 23 lcd.printf("Temp = %0.2f C",t); //Print Temperature Value on LCD first line
rx5 0:78a7d5cdbf61 24 lcd.locate(0,1); // cursor on Col=0, Raw=1
rx5 0:78a7d5cdbf61 25 lcd.printf("Humd = %0.2f %%",h); //Print Humidity Value on LCD Second line
rx5 0:78a7d5cdbf61 26 wait(1.0);
rx5 0:78a7d5cdbf61 27 }
rx5 0:78a7d5cdbf61 28 }