TaChing Yu / Mbed 2 deprecated LM35

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn lm35(A0);
00004 Serial pc(USBTX, USBRX);
00005 
00006 int main() {
00007     float val,tempC,tempF;
00008     while(1) 
00009     {
00010         val=lm35.read();
00011         tempC=(val*2.8f*100);
00012         tempF=(9.0f*tempC)/5.0f + 32.0f;
00013         printf("%.2f\n%.2f\n",tempC,tempF);
00014         wait(2);
00015     }
00016 }