Test code for MCP9700A Temperature Sensor

Dependencies:   mbed-src

Files at this revision

API Documentation at this revision

Comitter:
edodm85
Date:
Wed Aug 20 18:57:43 2014 +0000
Commit message:
First rev

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Wed Aug 20 18:57:43 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#17565898c031