A simple serial test program for the LM75B library.

Dependencies:   LM75B mbed

main.cpp

Committer:
neilt6
Date:
2014-05-30
Revision:
7:c2061c591c28
Parent:
2:a427f29fdfa0

File content as of revision 7:c2061c591c28:

#include "mbed.h"
#include "LM75B.h"

//Create an LM75B object at the default address (ADDRESS_0)
LM75B sensor(p28, p27);

int main()
{
    //Try to open the LM75B
    if (sensor.open()) {
        printf("Device detected!\n");

        while (1) {
            //Print the current temperature
            printf("Temp = %.3f\n", (float)sensor);

            //Sleep for 0.5 seconds
            wait(0.5);
        }
    } else {
        error("Device not detected!\n");
    }
}