![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
LM75Bをmbed LPC1114FN28に繋げて、温度をシリアルコンソールに出力するプログラム
Fork of LM75B_HelloWorld by
main.cpp@2:a427f29fdfa0, 2013-09-16 (annotated)
- Committer:
- neilt6
- Date:
- Mon Sep 16 21:38:37 2013 +0000
- Revision:
- 2:a427f29fdfa0
- Parent:
- 1:94af70628683
- Child:
- 8:08131df17a03
Updated to make use of float operator override, and default address
Who changed what in which revision?
User | Revision | Line number | New 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) |
neilt6 | 2:a427f29fdfa0 | 5 | LM75B sensor(p28, p27); |
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 | } |