Mario Simaremare / Mbed 2 deprecated mbed_measuring_temperature

Dependencies:   LinearAnalogSensors mbed

Fork of mbed_selectled by eka sinambela

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Serial pc(USBTX, USBRX);
00004 DigitalOut myled1(LED1), myled2(LED2);
00005 AnalogIn LM61(p15);
00006 
00007 char program_name[128] = "Serial IO";
00008 
00009 int main()
00010 {
00011     pc.printf("run: %s\n", program_name);
00012     float temp, tempC, tempF;
00013     while(1) {
00014         temp = LM61;
00015         tempC = ((temp*3.3)-0.600)*100.0;
00016         //convert to degrees F
00017         tempF = (9.0*tempC)/5.0 + 32.0;
00018         //print current temp
00019         printf("%5.2F : %5.2F C %5.2F F \n\r", temp, tempC, tempF);
00020         wait(2);
00021 
00022     }
00023 }