Hampus Lundberg / Mbed 2 deprecated analogtemperature

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
hample
Date:
Tue Jan 08 22:56:39 2019 +0000
Commit message:
miun

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	Tue Jan 08 22:56:39 2019 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+
+using namespace std;
+
+AnalogIn read_temp(PD4);
+
+float temp;
+uint16_t temp_hex;
+float temp_volt;
+float temp_ambient;
+
+int main()
+{
+    while(1)
+    {
+        temp = read_temp.read();
+        temp_hex = read_temp.read_u16();
+        temp_volt = temp*3.3;
+        
+        temp_ambient = (temp_volt - 0.5)/0.01;
+        
+        //printf("%f \r\n", temp);
+        printf("Hex: 0x%04X \r\n", temp_hex);
+        
+        printf("Voltage in: %.2f \r\n", temp_volt);
+        
+        printf("Ambient temperature: %.2f \r\n", temp_ambient);
+        
+        
+        
+        wait(1);
+    }
+}
+
+// 0.739
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jan 08 22:56:39 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file