Michiel B. / Mbed 2 deprecated TMP102_Serial_Logger

Dependencies:   mbed TMP102

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "TMP102.h"
00004 
00005 #define LF "\r\n"
00006 
00007 Serial pc(USBTX, USBRX); // tx, rx to PC
00008 
00009 TMP102 temperature(p9, p10, 0x90); //A0 pin is connected to ground
00010 
00011 int main()
00012 {
00013   pc.printf("TMP102 logger ready. Press 'u' to see the temperature." LF);
00014   
00015   while(1) {
00016     //whenever the computer sends a 'u', give it the current temperature.
00017     char c = pc.getc();
00018     if (c == 'u') {
00019         pc.printf("%f" LF, temperature.read());
00020     }
00021     wait(1);
00022   }
00023   return 0;
00024 }