Test code for MCP9700A Temperature Sensor
Diff: main.cpp
- Revision:
- 0:4418fc8bb525
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 20 18:57:43 2014 +0000 @@ -0,0 +1,36 @@ +/* + * Author: Edoardo De Marchi + * Date: 19-08-2014 + * Notes: Test code for MCP9700A Temperature Sensor +*/ + +#include "mbed.h" + +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); +AnalogIn temp(p15); + + +float TempRead() +{ + float Ta = 0.0; + + float t = temp.read(); //Read the input voltage + Ta = ((t * 3.3) - 0.5)/ 0.01; + + return Ta; // return the temp +} + + +int main() +{ + pc.baud(115200); + + while(1) + { + pc.printf("The Temp is: %2.2f deg C\n\r", TempRead()); + myled = !myled; + + wait(2); + } +} \ No newline at end of file