Takuo WATANABE
/
STTS751_Demo
A demo program for STTS751 (I2C temperature sensor library)
main.cpp@2:9850512c9113, 2014-01-19 (annotated)
- Committer:
- takuo
- Date:
- Sun Jan 19 03:16:15 2014 +0000
- Revision:
- 2:9850512c9113
- Parent:
- 1:8fb0961c0dc8
- Child:
- 3:a2d2563ae3ef
Now the example uses the stardard output (USB serial port) instead of I2C LCD.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takuo | 0:de38b1558115 | 1 | /** A demo program for STTS751 (I2C temperature sensor library) |
takuo | 0:de38b1558115 | 2 | * Takuo WATANABE (wtakuo) |
takuo | 0:de38b1558115 | 3 | * http://mbed.org/users/takuo/code/ACM1602NI/ |
takuo | 0:de38b1558115 | 4 | */ |
takuo | 0:de38b1558115 | 5 | |
takuo | 0:de38b1558115 | 6 | #include "mbed.h" |
takuo | 0:de38b1558115 | 7 | #include "STTS751.h" |
takuo | 0:de38b1558115 | 8 | |
takuo | 0:de38b1558115 | 9 | // I2C pins: p9 = sda, p10 = scl |
takuo | 1:8fb0961c0dc8 | 10 | STTS751 temp(p9, p10); |
takuo | 0:de38b1558115 | 11 | |
takuo | 0:de38b1558115 | 12 | // You can specify an I2C object instead. |
takuo | 0:de38b1558115 | 13 | // I2C i2c(p9, p10); |
takuo | 0:de38b1558115 | 14 | // STTS751 temp(i2c); |
takuo | 0:de38b1558115 | 15 | |
takuo | 0:de38b1558115 | 16 | int main() { |
takuo | 2:9850512c9113 | 17 | // set the temperature resolution to 12bits |
takuo | 2:9850512c9113 | 18 | temp.setResolution(STTS751::RES_12); |
takuo | 0:de38b1558115 | 19 | while (true) { |
takuo | 2:9850512c9113 | 20 | printf("temp: %.4f\n", (float)temp); |
takuo | 0:de38b1558115 | 21 | wait(1); |
takuo | 0:de38b1558115 | 22 | } |
takuo | 0:de38b1558115 | 23 | } |