A simple serial test program for the LM75B library.

Dependencies:   LM75B mbed

Committer:
neilt6
Date:
Wed Aug 28 17:44:28 2013 +0000
Revision:
1:94af70628683
Parent:
0:578bc3c56500
Child:
2:a427f29fdfa0
Added check for device connection before testing loop

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 0:578bc3c56500 4 LM75B sensor(p28, p27, LM75B::ADDRESS_0);
neilt6 0:578bc3c56500 5
neilt6 1:94af70628683 6 int main()
neilt6 1:94af70628683 7 {
neilt6 1:94af70628683 8 //Try to open the LM75B
neilt6 1:94af70628683 9 if (sensor.open()) {
neilt6 1:94af70628683 10 printf("Device detected!\n");
neilt6 0:578bc3c56500 11
neilt6 1:94af70628683 12 while (1) {
neilt6 1:94af70628683 13 //Read the temperature
neilt6 1:94af70628683 14 float temp = sensor.temp();
neilt6 0:578bc3c56500 15
neilt6 1:94af70628683 16 //Print the temperature
neilt6 1:94af70628683 17 printf("Temp = %.3f\n", temp);
neilt6 1:94af70628683 18
neilt6 1:94af70628683 19 //Sleep for 0.5 seconds
neilt6 1:94af70628683 20 wait(0.5);
neilt6 1:94af70628683 21 }
neilt6 1:94af70628683 22 } else {
neilt6 1:94af70628683 23 printf("Device not detected!\n");
neilt6 0:578bc3c56500 24 }
neilt6 0:578bc3c56500 25 }