LM75Bをmbed LPC1114FN28に繋げて、温度をシリアルコンソールに出力するプログラム

Dependencies:   LM75B mbed

Fork of LM75B_HelloWorld by Neil Thiessen

Committer:
jksoft
Date:
Wed Feb 03 14:48:49 2016 +0000
Revision:
8:08131df17a03
Parent:
2:a427f29fdfa0
?????mbed LPC1114FN28????

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)
jksoft 8:08131df17a03 5 LM75B sensor(dp5, dp27);
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 }