Lukas Buha / Mbed OS Mjerač temperature - Lukas Buha

Dependencies:   LM35 TextLCD

Files at this revision

API Documentation at this revision

Comitter:
lbuha
Date:
Mon Feb 22 02:01:29 2021 +0000
Commit message:
.;

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
LM35.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.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-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Mon Feb 22 02:01:29 2021 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM35.lib	Mon Feb 22 02:01:29 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/lbuha/code/LM35/#0604431a65be
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Mon Feb 22 02:01:29 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 22 02:01:29 2021 +0000
@@ -0,0 +1,73 @@
+//libraryji
+#include "mbed.h"
+#include "LM35.h"
+#include "TextLCD.h"
+
+
+InterruptIn button(USER_BUTTON); //okidač interrupt rutine
+Timer debounce;    //timer za istitravanje tastera
+TextLCD lcd (PC_8, PB_8, PC_6, PC_5, PA_12, PA_11); //pinovi LCDa
+Ticker ledtemp;     //Ticker za blicanje ledice
+Timer timer1;       //timer korišten u mainu
+DigitalOut led1(PA_10);    //ledica
+Serial pc(USBTX, USBRX);    //serijska komunikacija s računalom
+LM35 senzor(PC_0);          //senzor temperature
+float temperatura2;         //inicijalizacija varijable
+void interrupt (void);      //inicijalizacija funkcije
+DigitalOut svjetlo(PB_5);   //osvjetljenje LCDa
+
+//interupt funkcija
+void interrupt()
+{
+    if (debounce.read_ms()>200) {
+
+        svjetlo=!svjetlo;
+    }
+
+}
+
+//funkcija za blicanje ledica, tj. mijenjanje stanja ledice
+void ledica()
+{
+    led1=!led1;
+
+}
+
+
+//funkcija za određivanje frekvencije tickera, tj.frekvencije blicanja ledice
+void vizualizacija()
+{
+
+    if (temperatura2 > 15 && temperatura2 < 20)
+        ledtemp.attach(&ledica, 0.5);
+    else if (temperatura2> 20 && temperatura2 < 25)
+        ledtemp.attach(&ledica, 0.25);
+    else if (temperatura2 > 25)
+        ledtemp.attach(&ledica, 0.15);
+    else  led1=0;
+
+
+}
+
+//glavna funkcija
+int main()
+{
+    debounce.start();
+    timer1.start();
+    button.rise(&interrupt);
+    while(1) {
+        if(timer1.read_ms()>=1000) {
+            temperatura2 = senzor.mjerenje();
+            lcd.cls ();
+            lcd.printf("Temperatura je:", temperatura2);
+            lcd.locate (0,1);
+            lcd.printf("%.2f C", temperatura2);
+            vizualizacija();
+            timer1.reset();
+        }
+
+
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Feb 22 02:01:29 2021 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9