![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mission Accomplished
Diff: Temperature.cpp
- Revision:
- 0:96cf16c88314
diff -r 000000000000 -r 96cf16c88314 Temperature.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Temperature.cpp Wed Jan 20 01:01:04 2016 +0000 @@ -0,0 +1,25 @@ +#include "Temperature.h" +extern I2C acc; + +const int addr = 0x90; +char config_t[3]; +char temp_read[2]; +float temp; + +float Temperature() +{ + config_t[0] = 0x01; // Setting Up Temperature + config_t[1] = 0x60; + config_t[2] = 0xA0; + acc.write(addr,config_t,3); + config_t[0] =0x00; + acc.write(addr,config_t,1); + + + wait(.5); + acc.read(addr, temp_read,2); // Reading Temperature + temp= 0.0625*(((temp_read[0] << 8) + temp_read[1]) >> 4); // Converting Temperature to Celcius + + + return temp; +} \ No newline at end of file