Temperaturmessung mit LM35 auf Multifunktionshield

Dependencies:   ShiftReg mbed

Files at this revision

API Documentation at this revision

Comitter:
muellerhubert
Date:
Sun Apr 08 07:01:19 2018 +0000
Commit message:
Temperatur with LM35 and Multifunctionschield

Changed in this revision

ShiftReg.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 efab2162f523 ShiftReg.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ShiftReg.lib	Sun Apr 08 07:01:19 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/yoonghm/code/ShiftReg/#a0e3fd47970f
diff -r 000000000000 -r efab2162f523 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Apr 08 07:01:19 2018 +0000
@@ -0,0 +1,62 @@
+//LM35 auf Multifunktiionsshield A4 als Analogpin
+// Achtung LM35 mit runder Seite nach unten einstecken, abgeflachte Seite Richtung Anzeige.
+#include "mbed.h"
+#include "ShiftReg.h"
+
+AnalogIn LM35(A4);
+int tempC;
+unsigned short sensorValue;
+//#define ANZEIGE_MASKE 0x00000FFF
+//PortOut siebenSegPort(PortC, ANZEIGE_MASKE);
+const unsigned int siebenSegWerte[] = {0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09};
+const unsigned int enableWerte[] = {0x10,0x20,0x040,0x80};
+unsigned int ausgabeWerte[] = {0x03,0x03,0x03,0x03}; // 0 0 0 0
+unsigned int pos=0;
+
+ShiftReg HC595(D8, D4, D7);
+
+//  -------------------------      -------------------------
+// | D6 | D4 | D2 | D0 | GND |    | D6 | D4 | D2 | D0 | GND |
+// |-------------------------|    |-------------------------|
+// | D7 | D5 | D3 | D1 | VCC |    | D7 | D5 | D3 | D1 | VCC |
+//  -------------------------      -------------------------
+//  -------------------------      -------------------------
+// | NC | NC | en2| en0| GND |    |  g |  e |  c |  a | GND |
+// |-------------------------|    |-------------------------|
+// | NC | NC | en3| en1| VCC |    | dot|  f |  d |  b | VCC |
+//  -------------------------      -------------------------
+
+void ausgabe();
+void aufteilung();
+
+
+int main()
+{
+    HC595.ShiftByte(0x00, ShiftReg::LSBFirst); HC595.Latch(); wait(0.2);//Grundstellung
+    while(1) {
+        sensorValue=LM35.read_u16();
+        printf("measure = %i \n", sensorValue);
+        ausgabe();
+        wait_ms(1);
+        aufteilung();
+    }
+}
+void ausgabe()
+{
+    HC595.ShiftByte(ausgabeWerte[pos],ShiftReg::LSBFirst);
+    HC595.ShiftByte(enableWerte[pos],ShiftReg::LSBFirst);
+    HC595.Latch();
+   
+    pos++;
+    pos=pos%4;
+}
+void aufteilung()
+{
+    tempC=(sensorValue*2000/65536);    //hier sollte eigentlich 3300/65536 stehen, dann ist aber der Anzeigewert zu hoch
+                                         //Azeigewert 222 entspricht 22,2 Grad 
+        ausgabeWerte[0]=siebenSegWerte[tempC%10]; // Einer
+        ausgabeWerte[1]=siebenSegWerte[tempC%100/10]; //Zehner
+        ausgabeWerte[2]=siebenSegWerte[tempC%1000/100]; // Hunderter
+        ausgabeWerte[3]=siebenSegWerte[tempC/1000]; // Tausender
+    
+}
\ No newline at end of file
diff -r 000000000000 -r efab2162f523 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Apr 08 07:01:19 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file