Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- waltertakens
- Date:
- 2016-04-21
- Revision:
- 3:c29098fd46e7
- Parent:
- 2:99f52659d81d
File content as of revision 3:c29098fd46e7:
#include "mbed.h"
// veranderd!
//nog een keer veranderd 21 april walter
// Read temperature from TH06
// p6 PA_8 / XBEE_PWM0 / XBEE_RSSI / I2C_SCL D15
// p7 PC_9 / XBEE_PWM1 / I2C_SDA D14
I2C i2c(PC_9,PA_8);
const int addr = 0x80;
int main() {
char cmd[2];
while (1) {
cmd[0] = 0xf3;
i2c.write(addr, cmd, 1);
wait(0.5);
i2c.read(addr, cmd, 2);
float temp_code = (cmd[0]<<8)|cmd[1];
float temp = 175.72*temp_code/65535.0-46.85;
printf("Temp = %.2f\r\n", temp);
}
}