
LM75Bをmbed LPC1114FN28に繋げて、温度をシリアルコンソールに出力するプログラム
Fork of LM75B_HelloWorld by
Diff: main.cpp
- Revision:
- 2:a427f29fdfa0
- Parent:
- 1:94af70628683
- Child:
- 8:08131df17a03
--- 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"); } }