Robotics Kit Workshop / Mbed 2 deprecated Program2_TempAndHumidity

Dependencies:   DHT22 mbed

Revision:
2:90b2eb3d14e6
Parent:
0:c12c28a0f9e7
Child:
3:f215a9bec026
--- a/main.cpp	Tue Mar 10 21:33:31 2015 +0000
+++ b/main.cpp	Sat May 28 04:22:38 2016 +0000
@@ -1,27 +1,43 @@
+#include "mbed.h"   // this tells us to load mbed related functions
+#include "DHT.h"    // library for the Temp&Humidity sensor
 
-#include "mbed.h"
-#include "DHT.h"
+DHT sensor(D4, DHT11); // used as an ouput for the sensor
 
-DHT sensor(D4, DHT11);
-
+// this code runs when the microcontroller starts up
 int main()
 {
     int error = 0;
     float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
 
+    // spin a main loop all the time
     while(1) {
         wait(2.0f);
+        
+        // read data from the sensor
         error = sensor.readData();
+        
+        // read successfully
         if (0 == error) {
+            // read the temperature in CELCIUS
             c   = sensor.ReadTemperature(CELCIUS);
-            f   = sensor.ReadTemperature(FARENHEIT);
-            k   = sensor.ReadTemperature(KELVIN);
+            
+            // YOUR CODE HERE: read the temperature in FARENHEIT
+            
+            
+            // YOUR CODE HERE: read the temperature in KELVIN
+            
+            
+            // read the humidity and do the calculation
             h   = sensor.ReadHumidity();
             dp  = sensor.CalcdewPoint(c, h);
             dpf = sensor.CalcdewPointFast(c, h);
+            
+            // printf the temperature in Kelvin, Celcius and Farenheit
             printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
-            printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
-        } else {
+            
+            // YOUR CODE HERE: printf the humidity, dewpoint and dewpoint fast
+            
+        } else {  // read unseccessfully
             printf("Error: %d\n", error);
         }
     }