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

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:ce7a8546502b 1 #include "mbed.h"
chris 2:9e757151de9b 2 #include "LM75B.h"
chris 2:9e757151de9b 3 #include "C12832_lcd.h"
okano 0:ce7a8546502b 4
chris 2:9e757151de9b 5 C12832_LCD lcd;
chris 4:6df97cb10041 6 LM75B sensor(p28,p27);
chris 4:6df97cb10041 7 Serial pc(USBTX,USBRX);
okano 0:ce7a8546502b 8
chris 2:9e757151de9b 9 int main ()
okano 0:ce7a8546502b 10 {
okano 0:ce7a8546502b 11
chris 4:6df97cb10041 12 //Try to open the LM75B
chris 4:6df97cb10041 13 if (sensor.open()) {
chris 4:6df97cb10041 14 printf("Device detected!\n");
chris 4:6df97cb10041 15
chris 4:6df97cb10041 16 while (1) {
chris 4:6df97cb10041 17 lcd.cls();
chris 4:6df97cb10041 18 lcd.locate(0,3);
chris 4:6df97cb10041 19 lcd.printf("Temp = %.3f\n", (float)sensor);
chris 4:6df97cb10041 20 wait(1.0);
chris 4:6df97cb10041 21 }
chris 4:6df97cb10041 22
chris 4:6df97cb10041 23 } else {
chris 4:6df97cb10041 24 error("Device not detected!\n");
chris 2:9e757151de9b 25 }
okano 0:ce7a8546502b 26
okano 0:ce7a8546502b 27 }