A simple serial test program for the LM75B library.

Dependencies:   LM75B mbed

Committer:
neilt6
Date:
Mon Sep 16 21:38:37 2013 +0000
Revision:
2:a427f29fdfa0
Parent:
1:94af70628683
Updated to make use of float operator override, and default address

Who changed what in which revision?

UserRevisionLine numberNew contents of line
neilt6 0:578bc3c56500 1 #include "mbed.h"
neilt6 0:578bc3c56500 2 #include "LM75B.h"
neilt6 0:578bc3c56500 3
neilt6 2:a427f29fdfa0 4 //Create an LM75B object at the default address (ADDRESS_0)
neilt6 2:a427f29fdfa0 5 LM75B sensor(p28, p27);
neilt6 0:578bc3c56500 6
neilt6 1:94af70628683 7 int main()
neilt6 1:94af70628683 8 {
neilt6 1:94af70628683 9 //Try to open the LM75B
neilt6 1:94af70628683 10 if (sensor.open()) {
neilt6 1:94af70628683 11 printf("Device detected!\n");
neilt6 0:578bc3c56500 12
neilt6 1:94af70628683 13 while (1) {
neilt6 2:a427f29fdfa0 14 //Print the current temperature
neilt6 2:a427f29fdfa0 15 printf("Temp = %.3f\n", (float)sensor);
neilt6 1:94af70628683 16
neilt6 1:94af70628683 17 //Sleep for 0.5 seconds
neilt6 1:94af70628683 18 wait(0.5);
neilt6 1:94af70628683 19 }
neilt6 1:94af70628683 20 } else {
neilt6 2:a427f29fdfa0 21 error("Device not detected!\n");
neilt6 0:578bc3c56500 22 }
neilt6 0:578bc3c56500 23 }