Measuring temperature using sensor.
Dependencies: LinearAnalogSensors mbed
Fork of mbed_selectled by
Diff: main.cpp
- Revision:
- 1:6476db5e52e8
- Parent:
- 0:da915495c7fc
--- a/main.cpp Tue May 31 10:41:47 2016 +0000 +++ b/main.cpp Wed Jun 01 11:29:31 2016 +0000 @@ -2,24 +2,22 @@ Serial pc(USBTX, USBRX); DigitalOut myled1(LED1), myled2(LED2); +AnalogIn LM61(p15); -int main() { - +char program_name[128] = "Serial IO"; + +int main() +{ + pc.printf("run: %s\n", program_name); + float temp, tempC, tempF; while(1) { - char c = pc.getc(); - if (c=='q'){ - myled1 = 1; - wait(0.2); - myled1 = 0; - wait(0.2); - } - - if (c=='w'){ - myled2 = 1; - wait(0.2); - myled2 = 0; - wait(0.2); - } - + temp = LM61; + tempC = ((temp*3.3)-0.600)*100.0; + //convert to degrees F + tempF = (9.0*tempC)/5.0 + 32.0; + //print current temp + printf("%5.2F : %5.2F C %5.2F F \n\r", temp, tempC, tempF); + wait(2); + } }