An example program for the mbed application board that uses the LM75B to measure the ambient temperature

Dependencies:   mbed C12832 LM75B

Fork of LM75B_test by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
chris
Date:
Tue Oct 29 06:51:26 2013 +0000
Parent:
3:4d612f16ad84
Child:
5:608f2bf4d3f7
Commit message:
Updated to use Component database library for LM75BD

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
--- a/LM75B.lib	Fri Oct 26 21:42:06 2012 +0000
+++ b/LM75B.lib	Tue Oct 29 06:51:26 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
+http://mbed.org/users/neilt6/code/LM75B/#fc27dc535ea9
--- a/main.cpp	Fri Oct 26 21:42:06 2012 +0000
+++ b/main.cpp	Tue Oct 29 06:51:26 2013 +0000
@@ -3,16 +3,25 @@
 #include "C12832_lcd.h"
 
 C12832_LCD lcd;
-LM75B tmp(p28,p27);
+LM75B sensor(p28,p27);
+Serial pc(USBTX,USBRX);
 
 int main ()
 {
 
-    while (1) {
-        lcd.cls();
-        lcd.locate(0,3);
-        lcd.printf("%.2f\n",tmp.read());
-        wait(1.0);
+    //Try to open the LM75B
+    if (sensor.open()) {
+        printf("Device detected!\n");
+
+        while (1) {
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("Temp = %.3f\n", (float)sensor);
+            wait(1.0);
+        }
+
+    } else {
+        error("Device not detected!\n");
     }
 
 }