megan gimple / Mbed 2 deprecated gimple_A3_3_Temp_Light

Dependencies:   mbed

Revision:
2:38d752717527
Parent:
1:d706fb07041f
Child:
3:0170897aa173
--- a/main.cpp	Wed Oct 27 17:34:19 2021 +0000
+++ b/main.cpp	Wed Oct 27 17:48:12 2021 +0000
@@ -17,46 +17,48 @@
 float light_volt_raw; //raw voltage through photocell
 void temp_read();   //temperature reading function
 void light_read();  //light reading function
-void templight();   //lgith and temp reading function
+
 
 int main()
 {
     while(1) {
-        void temp_read(); //main temperature reading command to be called upon
-        {
-            volt_raw = therm.read(); //sets the raw data as a variable
-            volt = volt_raw*3.3; //converts raw voltage to the correct scale for our mbed
-            temp = -1481.96+sqrt(((2.1962e6)+((1.8639-volt)/(3.88e-6)))); //converts voltage to temperature
-            pc.printf("TEMP %f Volts %3.1f Celsius \r\n",volt, temp);
-            wait(1);
-            if (temp<50) {
+        temp_read();
+
+        light_read();
+    }
+}
 
-                if (temp>=20) {
-                    Led1=1;
-                    if (temp>=25) {
-                        Led2=1;
-                        if (temp>=30) {
-                            Led3=1;
-                        }
-                    }
-                }
+void temp_read() //main temperature reading command to be called upon
+{
+    volt_raw = therm.read(); //sets the raw data as a variable
+    volt = volt_raw; //converts raw voltage to the correct scale for our mbed *3.3
+    temp = -1481.96+sqrt(((2.1962e6)+((1.8639-volt)/(3.88e-6)))); //converts voltage to temperature
+    pc.printf("TEMP %f Volts %3.1f Celsius \r\n",volt, temp);
+    wait(1);
+
+    if (temp>=15) {
+        Led1=1;
+        if (temp>=20) {
+            Led2=1;
+            if (temp>=25) {
+                Led3=1;
             }
         }
+    }
+}
 
-        void light_read(); //main light reading command to be called upon
-        {
-            light_volt_raw=light.read(); //sets the raw data as a variable
-            light_res=(10000/light_volt_raw)-10000;     //converting voltage to resistance
-            light_volt=light_volt_raw*3.3;  //mbed outputs 3.3 volts
-            pc.printf("LIGHT %1.3f Voltz 6.2%f Ohms\r\n",light_volt,light_res);
-            wait(1);
-            if (light_volt<0.3) { //the sensor is "completely blocked" by a finger at most values under 0.3 volts. The whole photocell has to be covered however because even if a bit is showing it will read higher than 0.3
-                Led4=1;
-            }
-            if (light_volt>0.3) {
-                Led4=0;
-            }
-        }
 
+void light_read() //main light reading command to be called upon
+{
+    light_volt_raw=light.read(); //sets the raw data as a variable
+    light_res=(10000/light_volt_raw)-10000;     //converting voltage to resistance
+    light_volt=light_volt_raw*3.3;  //mbed outputs 3.3 volts
+    pc.printf("LIGHT %1.3f Voltz 6.2%f Ohms\r\n",light_volt,light_res);
+    wait(1);
+    if (light_volt<0.3) { //the sensor is "completely blocked" by a finger at most values under 0.3 volts. The whole photocell has to be covered however because even if a bit is showing it will read higher than 0.3
+        Led4=1;
     }
-}
\ No newline at end of file
+    if (light_volt>0.3) {
+        Led4=0;
+    }
+}