Program očitava temperaturu i vlažnost zraka u prostoriji pomoću senzora DHT11. Očitane vrijednosti ispisuje na računalu u programu Tera Term. Za vlažnost zraka manju od 60% svijetli zelena LED, a za vlažnost zraka veću od 60% pali se crvena LED. Pritiskom na tipkalo prekida se rad programa na 5sekundi. Odbrojavanje se prikazuje na 7-segmentnom displey-u. Za to vrijeme ugašene su sve LED. Nakon isteka 5 sekundi program nastavlja sa radom tamo di je prethodno stao. Žuta LED predstavlja ticker i blinka svake 0,2 sekunde i time pokazuje da se program izvršava.

Dependencies:   mbed Konstrukcijski Ledica

Files at this revision

API Documentation at this revision

Comitter:
MarioBlazevic
Date:
Tue Apr 06 12:14:24 2021 +0000
Commit message:

Changed in this revision

Dht11.lib Show annotated file Show diff for this revision Revisions of this file
Ledica.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2bff2d7980f2 Dht11.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dht11.lib	Tue Apr 06 12:14:24 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/TVZ2020/code/Konstrukcijski/#d2e26e6fa11b
diff -r 000000000000 -r 2bff2d7980f2 Ledica.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ledica.lib	Tue Apr 06 12:14:24 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/TVZ2020/code/Ledica/#b3bc716e5bea
diff -r 000000000000 -r 2bff2d7980f2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 06 12:14:24 2021 +0000
@@ -0,0 +1,91 @@
+#include "mbed.h"
+#include "dht11.h"
+#include "Ledica.h"
+
+InterruptIn Button(D7);
+Timer debounce;
+Ticker flipper;
+Serial pc(USBTX, USBRX);
+Dht11 sensor(D8);
+Ledica zutaled(D2);
+Ledica zelenaled(D14);
+Ledica crvenaled(D13);
+DigitalOut A(D4);
+DigitalOut B(D3);
+DigitalOut C(D11);
+DigitalOut D(D10);
+DigitalOut E(D9);
+DigitalOut F(D5);
+DigitalOut G(D6);
+DigitalOut DP(D12); 
+ 
+ void prekid(){
+     
+     if (debounce.read_ms()>300)
+     
+     
+     zutaled.status(0);
+    crvenaled.status(0);
+    zelenaled.status(0);
+     
+A=1; B=0; C=1; D=1; E=0; F=1; G=1; DP=0; // set LEDs '5'
+ wait(1);
+ 
+A=0; B=1; C=1; D=0; E=0; F=1; G=1; DP=0; // set LEDs '4'
+ wait(1);
+ 
+A=1; B=1; C=1; D=1; E=0; F=0; G=1; DP=0; // set LEDs '3'
+ wait(1);
+ 
+A=1; B=1; C=0; D=1; E=1; F=0; G=1; DP=0; // set LEDs '2'
+ wait(1);
+ 
+A=0; B=1; C=1; D=0; E=0; F=0; G=0; DP=0; // set LEDs '1'
+ wait(1);
+ 
+ 
+A=0; B=0; C=0; D=0; E=0; F=0; G=0; DP=0; // set LEDs '0'
+    
+    debounce.reset();
+}
+     
+     
+void flip(){
+     
+     zutaled.flipp();
+     
+     }
+     
+     
+int main() {
+    
+     zutaled.status(0);
+    crvenaled.status(0);
+    zelenaled.status(0);
+    
+    debounce.start();
+    Button.rise(&prekid);
+    flipper.attach(&flip,0.2);
+    
+  
+    
+    
+while(1){
+      
+      sensor.read();
+     pc.printf("Temperatura: %d, Vlaznost: %d\r\n", sensor.getCelsius(), sensor.getHumidity());
+     wait(1);
+     
+    if (sensor.getHumidity()<60){
+        
+        zelenaled.status(1);
+        crvenaled.status(0);
+        
+        } else{
+            
+            zelenaled.status(0);
+            crvenaled.status(1);
+            
+            }
+ }
+ }
\ No newline at end of file
diff -r 000000000000 -r 2bff2d7980f2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Apr 06 12:14:24 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file