Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DHT TextLCD mbed
Fork of programski_zadatak_senzor by
Diff: main.cpp
- Revision:
- 0:296aeee1e970
diff -r 000000000000 -r 296aeee1e970 main.cpp
--- /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
