Seeedstudio Arch Examples : Temperature sensing using thermistor and AnalogIn interface.
Fork of Arch_GPIO_Ex4 by
Revision 6:914bd412ceda, committed 2013-10-08
- Comitter:
- viswesr
- Date:
- Tue Oct 08 08:53:33 2013 +0000
- Parent:
- 5:d035275d4c21
- Commit message:
- Removed USB Debug
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d035275d4c21 -r 914bd412ceda main.cpp --- a/main.cpp Mon Oct 07 13:10:03 2013 +0000 +++ b/main.cpp Tue Oct 08 08:53:33 2013 +0000 @@ -1,5 +1,4 @@ #include "mbed.h" -#include "USBSerial.h" AnalogIn thermistor(P0_11); /* Thermistor output connected to P0_11 */ @@ -15,7 +14,7 @@ a = thermistor.read_u16(); /* Read analog value */ /* Calculate the resistance of the thermistor from analog votage read. */ - resistance= (float) 10000.0 * (1.0 - (a / 65536.0 )); + resistance= (float) 10000.0 * ((65536.0 / a) - 1.0); /* Convert the resistance to temperature using Steinhart's Hart equation */ temperature=(1/((log(resistance/5000.0)/beta) + (1.0/298.15)))-273.15;