aboutsummaryrefslogtreecommitdiff
path: root/assignments/old/read-temperature/solution/read-temperature
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-06-13 20:41:24 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-06-13 20:41:24 +0200
commita4cbbee0671ff20560c31a2f3945b6131496ab2b (patch)
tree7b3a7d80db0eb3377d87bb812a3cc233f7f0cd4d /assignments/old/read-temperature/solution/read-temperature
parente4bdeee49319bc5570dfa0e998e4e68f3c33ee8c (diff)
downloadiot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.gz
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.bz2
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.xz
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.zip
wip
Diffstat (limited to 'assignments/old/read-temperature/solution/read-temperature')
-rw-r--r--assignments/old/read-temperature/solution/read-temperature/read-temperature.ino24
1 files changed, 24 insertions, 0 deletions
diff --git a/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino b/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino
new file mode 100644
index 0000000..b261dc5
--- /dev/null
+++ b/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino
@@ -0,0 +1,24 @@
+#include <DHT.h>
+#include <DHT_U.h>
+
+const auto DHTPIN = D1;
+const auto DHTTYPE = DHT22;
+
+DHT_Unified dht(DHTPIN, DHTTYPE);
+
+void setup() {
+ Serial.begin(115200);
+ pinMode(D2, INPUT);
+ pinMode(D0, OUTPUT);
+}
+
+void loop() {
+ if (digitalRead(D2) == HIGH) {
+ Serial.println("HIGH");
+ } else {
+ Serial.println("LOW");
+ }
+ digitalWrite(D0, digitalRead(D2));
+ delay(100);
+}
+