
A simple serial test program for the LM75B library.
Revision 1:94af70628683, committed 2013-08-28
- Comitter:
- neilt6
- Date:
- Wed Aug 28 17:44:28 2013 +0000
- Parent:
- 0:578bc3c56500
- Child:
- 2:a427f29fdfa0
- Commit message:
- Added check for device connection before testing loop
Changed in this revision
--- a/LM75B.lib Wed Aug 14 05:03:01 2013 +0000 +++ b/LM75B.lib Wed Aug 28 17:44:28 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/neilt6/code/LM75B/#2b797c309258 +http://mbed.org/users/neilt6/code/LM75B/#9bd544dd9e07
--- a/main.cpp Wed Aug 14 05:03:01 2013 +0000 +++ b/main.cpp Wed Aug 28 17:44:28 2013 +0000 @@ -3,15 +3,23 @@ LM75B sensor(p28, p27, LM75B::ADDRESS_0); -int main() { - while (1) { - //Read the temperature - float temp = sensor.temp(); +int main() +{ + //Try to open the LM75B + if (sensor.open()) { + printf("Device detected!\n"); - //Print the temperature - printf("Temp = %.3f\n", temp); + while (1) { + //Read the temperature + float temp = sensor.temp(); - //Sleep for 0.5 seconds - wait(0.5); + //Print the temperature + printf("Temp = %.3f\n", temp); + + //Sleep for 0.5 seconds + wait(0.5); + } + } else { + printf("Device not detected!\n"); } }
--- a/mbed.bld Wed Aug 14 05:03:01 2013 +0000 +++ b/mbed.bld Wed Aug 28 17:44:28 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/5798e58a58b1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9c8f0e3462fb \ No newline at end of file