edge / Mbed 2 deprecated EdgeTeamTest

Dependencies:   libmDot mbed

Committer:
waltertakens
Date:
Thu Apr 21 08:55:45 2016 +0000
Revision:
3:c29098fd46e7
Parent:
2:99f52659d81d
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boddeke 0:0a5a8dae0fa1 1 #include "mbed.h"
boddeke 0:0a5a8dae0fa1 2
boddeke 1:7baef237c57c 3 // veranderd!
waltertakens 3:c29098fd46e7 4
waltertakens 3:c29098fd46e7 5 //nog een keer veranderd 21 april walter
boddeke 1:7baef237c57c 6
boddeke 0:0a5a8dae0fa1 7 // Read temperature from TH06
boddeke 0:0a5a8dae0fa1 8
boddeke 0:0a5a8dae0fa1 9 // p6 PA_8 / XBEE_PWM0 / XBEE_RSSI / I2C_SCL D15
boddeke 0:0a5a8dae0fa1 10 // p7 PC_9 / XBEE_PWM1 / I2C_SDA D14
boddeke 0:0a5a8dae0fa1 11 I2C i2c(PC_9,PA_8);
boddeke 0:0a5a8dae0fa1 12
boddeke 0:0a5a8dae0fa1 13 const int addr = 0x80;
boddeke 0:0a5a8dae0fa1 14
boddeke 0:0a5a8dae0fa1 15 int main() {
boddeke 0:0a5a8dae0fa1 16 char cmd[2];
boddeke 0:0a5a8dae0fa1 17
boddeke 0:0a5a8dae0fa1 18 while (1) {
boddeke 0:0a5a8dae0fa1 19 cmd[0] = 0xf3;
boddeke 0:0a5a8dae0fa1 20 i2c.write(addr, cmd, 1);
boddeke 0:0a5a8dae0fa1 21
boddeke 0:0a5a8dae0fa1 22 wait(0.5);
boddeke 0:0a5a8dae0fa1 23
boddeke 0:0a5a8dae0fa1 24 i2c.read(addr, cmd, 2);
boddeke 0:0a5a8dae0fa1 25
boddeke 0:0a5a8dae0fa1 26 float temp_code = (cmd[0]<<8)|cmd[1];
boddeke 0:0a5a8dae0fa1 27 float temp = 175.72*temp_code/65535.0-46.85;
boddeke 0:0a5a8dae0fa1 28
boddeke 0:0a5a8dae0fa1 29 printf("Temp = %.2f\r\n", temp);
boddeke 0:0a5a8dae0fa1 30 }
boddeke 0:0a5a8dae0fa1 31 }