LPC_EI_I2C_TEMP
Dependencies: mbed
Revision 0:d47654dea5c5, committed 2018-03-15
- Comitter:
- Lenschinki
- Date:
- Thu Mar 15 11:45:07 2018 +0000
- Commit message:
- FSST 15.03
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r d47654dea5c5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 15 11:45:07 2018 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" + +I2C i2ca(p28,p27); +Serial pc(USBTX,USBRX); + +int main() { + pc.baud(115200); + i2ca.frequency(400000); + pc.printf("Temperaturmessung \n"); + + i2ca.start(); + i2ca.write(0x90); + i2ca.write(0x01); + i2ca.write(0x00); + i2ca.stop(); + + unsigned char msb, lsb; + int itemp; + float temp; + + while(1) { + i2ca.start(); + i2ca.write(0x90); + i2ca.write(0x00); + + i2ca.start(); + i2ca.write(0x91); + msb = i2ca.read(1); + lsb = i2ca.read(0); + i2ca.stop(); + + itemp = (msb <<8) + lsb; + temp = (float)itemp/256.0; + + pc.printf("Temperatur: %8.3f Grad C \n",temp); + + wait(1.0); + } +}
diff -r 000000000000 -r d47654dea5c5 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Mar 15 11:45:07 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/aa5281ff4a02 \ No newline at end of file