Grove Temp sensor Hello world example
Dependencies: Grove_temp_sensor mbed
main.cpp@3:056a7a65f807, 2016-03-10 (annotated)
- Committer:
- peipei123
- Date:
- Thu Mar 10 19:42:29 2016 +0000
- Revision:
- 3:056a7a65f807
- Parent:
- 1:e3c235c7edaf
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peipei123 | 0:3fa32ef93fdc | 1 | #include "mbed.h" |
peipei123 | 0:3fa32ef93fdc | 2 | #include "Grove_temp_sensor.h" |
peipei123 | 3:056a7a65f807 | 3 | // This is the hello world example how to use this sensor |
peipei123 | 3:056a7a65f807 | 4 | |
peipei123 | 3:056a7a65f807 | 5 | //creat sensor object |
peipei123 | 1:e3c235c7edaf | 6 | Grove_temp_sensor input(p15); |
peipei123 | 3:056a7a65f807 | 7 | //set up usb serial port |
peipei123 | 1:e3c235c7edaf | 8 | Serial pc(USBTX, USBRX); |
peipei123 | 0:3fa32ef93fdc | 9 | int main() { |
peipei123 | 0:3fa32ef93fdc | 10 | double temp; |
peipei123 | 0:3fa32ef93fdc | 11 | while(1) { |
peipei123 | 3:056a7a65f807 | 12 | //read the temperature here |
peipei123 | 3:056a7a65f807 | 13 | temp = input.read_F(); |
peipei123 | 1:e3c235c7edaf | 14 | printf("The temperature is: %5.2F F \n\r", temp); |
peipei123 | 1:e3c235c7edaf | 15 | wait(0.5); |
peipei123 | 0:3fa32ef93fdc | 16 | } |
peipei123 | 0:3fa32ef93fdc | 17 | } |