Hampus Lundberg / Mbed 2 deprecated analogtemperature

Dependencies:   mbed

Revision:
0:91a5544963d7
--- /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