Thermometer with light amplitude

Dependencies:   LM75B mbed

Files at this revision

API Documentation at this revision

Comitter:
niclasesterl
Date:
Tue May 24 11:35:23 2016 +0000
Commit message:
You can use it to messure temperature

Changed in this revision

LM75B.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Tue May 24 11:35:23 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/neilt6/code/LM75B/#7ac462ba84ac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 24 11:35:23 2016 +0000
@@ -0,0 +1,183 @@
+#include "mbed.h"
+#include "LM75B.h"
+// ********   Definitionen  **********
+Serial pc(USBTX, USBRX);
+
+// Definition der Taster (Switches)
+DigitalIn  sw1(P0_10); //SW1
+DigitalIn  sw2(P0_15); //SW2 -> sein IO Pin ist laut Schaltplan der P0_15
+DigitalIn  sw3(P0_23); //SW3
+DigitalIn  sw4(P1_16); //SW4 
+
+// Definition der 12 LED's
+DigitalOut ledD1(P1_8);
+DigitalOut ledD2(P1_9);
+DigitalOut ledD3(P1_10);
+DigitalOut ledD4(P1_11);
+DigitalOut ledD13(P1_0);
+DigitalOut ledD14(P1_1);
+DigitalOut ledD15(P1_3);
+DigitalOut ledD16(P1_4);
+DigitalOut ledD17(P1_6);
+DigitalOut ledD18(P1_7);
+DigitalOut ledD19(P1_12);
+DigitalOut ledD20(P1_13);
+
+// RGB LED
+DigitalOut ledRT(P0_9);   // rote LED
+DigitalOut ledGR(P1_15);  // grüne LED
+DigitalOut ledBL(P0_21);  // blau  LED
+// LDR Input
+AnalogIn LDR(P0_12);      // Analoges einlesen des LDR 
+AnalogIn POTI (P0_11);    // Analog in des POTI
+//Create an LM75B object at the default address (ADDRESS_0)
+LM75B sensor(p28, p27);    //i²C Sensor Leitungen
+
+
+void ledOn(int x);
+int main(){
+    while(1){
+        int newSensor = sensor-5;
+        if(sw1==1){
+            pc.printf("Temperatur = %d Grad\n\r", newSensor);
+            ledOn(newSensor);
+        } 
+        wait(1);
+    
+    }   
+}
+void ledOn(int x){
+    
+        ledD1 = 0;
+        ledD2 = 0;
+        ledD3 = 0;
+        ledD4 = 0;
+        ledD13 = 0;
+        ledD14 = 0;
+        ledD15 = 0;
+        ledD16 = 0;
+        ledD17 = 0;
+        ledD18 = 0;
+        ledD19 = 0;
+        ledD20 = 0;
+        ledBL = 0;
+        ledGR = 0;
+        ledRT = 0;
+        
+        if (x < 25){
+        ledRT = 0;
+        ledBL = 1;
+        ledGR = 0;
+        }
+        if(x > 25){
+            ledBL = 0;
+            ledGR = 0;
+            ledRT = 1;
+        }
+    if (x == 20){
+        ledD1 = 1;
+    }
+    if (x == 21){
+        ledD1 = 1;
+        ledD2 = 1;
+    }
+    if (x == 22){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+    }
+    if (x == 23){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+    }
+    if (x == 24){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+    }
+
+    if (x == 25){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledGR = 1;
+        ledBL = 0;
+        ledRT = 0;
+    }
+    else if (x == 26){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+    }
+    else if (x == 27){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+        ledD16 = 1;
+    }
+    else if (x == 28){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+        ledD16 = 1;
+        ledD17 = 1;
+    }
+    else if (x == 29){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+        ledD16 = 1;
+        ledD17 = 1;
+        ledD18 = 1;
+    }
+    else if (x == 30){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+        ledD16 = 1;
+        ledD17 = 1;
+        ledD18 = 1;
+        ledD19 = 1;
+    }
+    else if (x > 30){
+        ledD1 = 1;
+        ledD2 = 1;
+        ledD3 = 1;
+        ledD4 = 1;
+        ledD13 = 1;
+        ledD14 = 1;
+        ledD15 = 1;
+        ledD16 = 1;
+        ledD17 = 1;
+        ledD18 = 1;
+        ledD19 = 1;
+        ledD20 = 1;
+    }
+} 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue May 24 11:35:23 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file