Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Arch_Analog_Thermistor_Blinker by
main.cpp
- Committer:
- viswesr
- Date:
- 2013-10-08
- Revision:
- 6:914bd412ceda
- Parent:
- 5:d035275d4c21
- Child:
- 7:5c2ade6745ae
File content as of revision 6:914bd412ceda:
#include "mbed.h" AnalogIn thermistor(P0_11); /* Thermistor output connected to P0_11 */ DigitalOut tensplaceLED(LED4); /* This led blinks as per tens place of temperature value(in deg C) */ DigitalOut unitsplaceLED(LED1); /* This led blinks as per units place of temperature value(in deg C) */ int main() { unsigned int a, beta = 3975, units, tens; 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/5000.0)/beta) + (1.0/298.15)))-273.15; units = (int) temperature % 10; tens = (int) temperature / 10; for(int i=0; i< tens; i++) { tensplaceLED = 1; wait(.200); tensplaceLED = 0; wait(.200); } for(int i=0; i< units; i++) { unitsplaceLED = 1; wait(.200); unitsplaceLED = 0; wait(.200); } wait(0.5); } }