A simple serial test program for the LM75B library.

Dependencies:   LM75B mbed

Files at this revision

API Documentation at this revision

Comitter:
neilt6
Date:
Mon Sep 16 21:38:37 2013 +0000
Parent:
1:94af70628683
Child:
3:e49cf426305d
Commit message:
Updated to make use of float operator override, and default address

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	Wed Aug 28 17:44:28 2013 +0000
+++ b/LM75B.lib	Mon Sep 16 21:38:37 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/neilt6/code/LM75B/#9bd544dd9e07
+http://mbed.org/users/neilt6/code/LM75B/#fc27dc535ea9
--- a/main.cpp	Wed Aug 28 17:44:28 2013 +0000
+++ b/main.cpp	Mon Sep 16 21:38:37 2013 +0000
@@ -1,7 +1,8 @@
 #include "mbed.h"
 #include "LM75B.h"
 
-LM75B sensor(p28, p27, LM75B::ADDRESS_0);
+//Create an LM75B object at the default address (ADDRESS_0)
+LM75B sensor(p28, p27);
 
 int main()
 {
@@ -10,16 +11,13 @@
         printf("Device detected!\n");
 
         while (1) {
-            //Read the temperature
-            float temp = sensor.temp();
-
-            //Print the temperature
-            printf("Temp = %.3f\n", temp);
+            //Print the current temperature
+            printf("Temp = %.3f\n", (float)sensor);
 
             //Sleep for 0.5 seconds
             wait(0.5);
         }
     } else {
-        printf("Device not detected!\n");
+        error("Device not detected!\n");
     }
 }