megan gimple / Mbed 2 deprecated gimple_A3_3_Temp_Light

Dependencies:   mbed

Revision:
1:d706fb07041f
Parent:
0:61f876d07ef5
Child:
2:38d752717527
--- a/main.cpp	Wed Oct 27 16:31:41 2021 +0000
+++ b/main.cpp	Wed Oct 27 17:34:19 2021 +0000
@@ -21,41 +21,42 @@
 
 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) {
 
-    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) {
-
-            if (temp>=20) {
-                Led1=1;
-                if (temp>=25) {
-                    Led2=1;
-                    if (temp>=30) {
-                        Led3=1;
+                if (temp>=20) {
+                    Led1=1;
+                    if (temp>=25) {
+                        Led2=1;
+                        if (temp>=30) {
+                            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;
+        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;
+            }
         }
-        if (light_volt>0.3) {
-            Led4=0;
-        }
+
     }
-
 }
\ No newline at end of file