A digital thermometer
Dependencies: DigitDisplay mbed
Revision 0:9fd28909b48d, committed 2014-04-28
- Comitter:
- yihui
- Date:
- Mon Apr 28 01:11:23 2014 +0000
- Commit message:
- initial
Changed in this revision
diff -r 000000000000 -r 9fd28909b48d DigitDisplay.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DigitDisplay.lib Mon Apr 28 01:11:23 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
diff -r 000000000000 -r 9fd28909b48d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 28 01:11:23 2014 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" +#include "DigitDisplay.h" + +DigitDisplay display(P1_14, P1_13); // 4-Digit Display connected to UART Grove connector +AnalogIn thermistor(P0_12); // Thermistor output connected to P0_12 + +int main() { + unsigned int a; + unsigned int beta = 3975; + float temperature, resistance; + + while(1) { + a = thermistor.read_u16(); /* Read analog value */ + + /* Calculate the resistance of the thermistor from analog votage read. */ + resistance= (float) 10000.0 * ((65536.0 / a) - 1.0); + + /* Convert the resistance to temperature using Steinhart's Hart equation */ + temperature = (1/((log(resistance/10000.0)/beta) + (1.0/298.15)))-273.15; + + display = (int)temperature; + + wait(0.5); + } +}
diff -r 000000000000 -r 9fd28909b48d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 28 01:11:23 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file