mariozavršni
Dependencies: DHT TextLCD mbed
Fork of temperaturaivlaga by
Diff: main.cpp
- Revision:
- 0:296aeee1e970
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 22 13:50:20 2016 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "DHT.h" + +TextLCD lcd(p19, p20, p21, p22, p23, p24, TextLCD::LCD8x2); +DHT sensor(p26, DHT11); +DigitalOut myled(p25); +AnalogIn Ain(p17); + +int err; +float c, h, alarm; +int main() +{ + while (1) { + wait(2); + err = sensor.readData(); + alarm=Ain*50.0; + if (err == 0) { + c = sensor.ReadTemperature(CELCIUS); + h = sensor.ReadHumidity(); + lcd.locate(0, 0); + lcd.printf("T %3.1f ", c); + lcd.locate(1, 1); + lcd.printf("H %3.1f ", h); + if(c>alarm) { + myled=true; + } else { + myled=false; + } + wait(0.5); + } + } +} \ No newline at end of file