Testing Temperature sensors

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
irayya
Date:
Thu May 25 06:04:57 2017 +0000
Commit message:
Temperature sensor

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld 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	Thu May 25 06:04:57 2017 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+
+AnalogIn temp(A1);
+Serial pc(USBTX,USBRX);
+DigitalOut LED(D0);
+
+int main()
+{
+    float tempC, tempF;
+
+    while(1) {
+        //conversion to degrees C - from sensor output voltage 
+        float tempout=temp.read();
+        pc.printf("analog value of temperature sensor is %f: ",tempout);
+
+        tempC = ((tempout*3.3)-0.600)*100.0;
+        //convert to degrees F
+        tempF = (9.0*tempC)/5.0 + 32.0;
+        //print the temp
+        printf("%5.2F C %5.2F F \n\r", tempC, tempF);
+        wait(0.5);
+        
+        if(tempC>35.30)
+        {
+            LED=1;
+            wait(1);
+            LED=0;
+            }
+            else
+            LED=0;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 25 06:04:57 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file