Measuring temperature using sensor.
Dependencies: LinearAnalogSensors mbed
Fork of mbed_selectled by
Revision 1:6476db5e52e8, committed 2016-06-01
- Comitter:
- mariosimaremare
- Date:
- Wed Jun 01 11:29:31 2016 +0000
- Parent:
- 0:da915495c7fc
- Commit message:
- Measuring temperature using sensor.
Changed in this revision
LinearAnalogSensors.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LinearAnalogSensors.lib Wed Jun 01 11:29:31 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/PennElectric/code/LinearAnalogSensors/#989048937c77
--- 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); + } }