Hampus Lundberg / Mbed 2 deprecated analogtemperature

Dependencies:   mbed

Committer:
hample
Date:
Tue Jan 08 22:56:39 2019 +0000
Revision:
0:91a5544963d7
miun

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hample 0:91a5544963d7 1 #include "mbed.h"
hample 0:91a5544963d7 2
hample 0:91a5544963d7 3 using namespace std;
hample 0:91a5544963d7 4
hample 0:91a5544963d7 5 AnalogIn read_temp(PD4);
hample 0:91a5544963d7 6
hample 0:91a5544963d7 7 float temp;
hample 0:91a5544963d7 8 uint16_t temp_hex;
hample 0:91a5544963d7 9 float temp_volt;
hample 0:91a5544963d7 10 float temp_ambient;
hample 0:91a5544963d7 11
hample 0:91a5544963d7 12 int main()
hample 0:91a5544963d7 13 {
hample 0:91a5544963d7 14 while(1)
hample 0:91a5544963d7 15 {
hample 0:91a5544963d7 16 temp = read_temp.read();
hample 0:91a5544963d7 17 temp_hex = read_temp.read_u16();
hample 0:91a5544963d7 18 temp_volt = temp*3.3;
hample 0:91a5544963d7 19
hample 0:91a5544963d7 20 temp_ambient = (temp_volt - 0.5)/0.01;
hample 0:91a5544963d7 21
hample 0:91a5544963d7 22 //printf("%f \r\n", temp);
hample 0:91a5544963d7 23 printf("Hex: 0x%04X \r\n", temp_hex);
hample 0:91a5544963d7 24
hample 0:91a5544963d7 25 printf("Voltage in: %.2f \r\n", temp_volt);
hample 0:91a5544963d7 26
hample 0:91a5544963d7 27 printf("Ambient temperature: %.2f \r\n", temp_ambient);
hample 0:91a5544963d7 28
hample 0:91a5544963d7 29
hample 0:91a5544963d7 30
hample 0:91a5544963d7 31 wait(1);
hample 0:91a5544963d7 32 }
hample 0:91a5544963d7 33 }
hample 0:91a5544963d7 34
hample 0:91a5544963d7 35 // 0.739