
Read Temperature from Temperature sensor and display on Serial
Dependencies: C12832 LM75B mbed
main.cpp@0:6dcecb339af3, 2015-10-06 (annotated)
- Committer:
- dwijaybane
- Date:
- Tue Oct 06 09:59:20 2015 +0000
- Revision:
- 0:6dcecb339af3
- Child:
- 1:1c42336484a8
Print Temperature on Serial;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dwijaybane | 0:6dcecb339af3 | 1 | #include "mbed.h" |
dwijaybane | 0:6dcecb339af3 | 2 | #include "LM75B.h" |
dwijaybane | 0:6dcecb339af3 | 3 | |
dwijaybane | 0:6dcecb339af3 | 4 | LM75B tmp(p28,p27); //I2C Temperature Sensor |
dwijaybane | 0:6dcecb339af3 | 5 | Serial pc(USBTX, USBRX); // tx, rx |
dwijaybane | 0:6dcecb339af3 | 6 | |
dwijaybane | 0:6dcecb339af3 | 7 | int main () |
dwijaybane | 0:6dcecb339af3 | 8 | { |
dwijaybane | 0:6dcecb339af3 | 9 | float board_temp; |
dwijaybane | 0:6dcecb339af3 | 10 | |
dwijaybane | 0:6dcecb339af3 | 11 | while (1) { |
dwijaybane | 0:6dcecb339af3 | 12 | board_temp = tmp; //read temperature |
dwijaybane | 0:6dcecb339af3 | 13 | pc.printf("Board Temperature = %.2f\n\r",board_temp); |
dwijaybane | 0:6dcecb339af3 | 14 | wait(1.0); |
dwijaybane | 0:6dcecb339af3 | 15 | } |
dwijaybane | 0:6dcecb339af3 | 16 | } |