...

Dependencies:   C12832 LM75B mbed

Fork of app-board-LM75B by Chris Styles

Revision:
6:4f08697d42cc
Parent:
5:608f2bf4d3f7
--- a/main.cpp	Thu Feb 06 14:05:51 2014 +0000
+++ b/main.cpp	Wed Feb 15 10:59:49 2017 +0000
@@ -1,28 +1,30 @@
+
 #include "mbed.h"
-#include "LM75B.h"
 #include "C12832.h"
-
+ 
 C12832 lcd(p5, p7, p6, p8, p11);
-
-LM75B sensor(p28,p27);
-Serial pc(USBTX,USBRX);
-
-int main ()
-{
+AnalogIn sensor(p15);       
 
-    //Try to open the LM75B
-    if (sensor.open()) {
-        printf("Device detected!\n");
+                         
+float multiplier = 50;    // this number got me closest to the reading on my multimeter temp probe
+float temp;               // calculated temperature
+int count;                // for computing average reading
+float total;
+float average;
+int main() {
+    count = 0;
+    total = 0.0;
+    while (1) {
+        // formula is analog reading * multiplier
 
-        while (1) {
-            lcd.cls();
-            lcd.locate(0,3);
-            lcd.printf("Temp = %.3f\n", (float)sensor);
-            wait(1.0);
-        }
-
-    } else {
-        error("Device not detected!\n");
+        temp = sensor.read() * multiplier;
+        count++;
+        total += temp;
+        average = total / count;
+        
+        lcd.cls();
+        lcd.locate(0,3);
+        lcd.printf("Temperature= %6.2f \n Average= %5.1f \n", temp  , average );
+        wait(1);
     }
-
 }