Junichi Katsu
/
Analog_Temp_Sensor
ワークショップ用に公開しているものです。
Fork of Arch_Analog_Thermistor_Blinker by
Diff: main.cpp
- Revision:
- 6:914bd412ceda
- Parent:
- 5:d035275d4c21
- Child:
- 7:5c2ade6745ae
--- 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;