![](/media/cache/profiles/4206e38996fae4028a26d43b24f68d32.jpg.50x50_q85.png)
A demo program for STTS751 (I2C temperature sensor library)
main.cpp@1:8fb0961c0dc8, 2014-01-18 (annotated)
- Committer:
- takuo
- Date:
- Sat Jan 18 02:36:42 2014 +0000
- Revision:
- 1:8fb0961c0dc8
- Parent:
- 0:de38b1558115
- Child:
- 2:9850512c9113
Fixed the variable name (tmp -> temp)
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 | |
takuo | 0:de38b1558115 | 8 | // I2C Text LCD: http://mbed.org/users/takuo/code/ACM1602NI/ |
takuo | 0:de38b1558115 | 9 | #include "ACM1602NI.h" |
takuo | 0:de38b1558115 | 10 | // I2C Temperature Sensor: http://mbed.org/users/takuo/code/STTS751/ |
takuo | 0:de38b1558115 | 11 | #include "STTS751.h" |
takuo | 0:de38b1558115 | 12 | |
takuo | 0:de38b1558115 | 13 | // I2C pins: p9 = sda, p10 = scl |
takuo | 0:de38b1558115 | 14 | ACM1602NI lcd(p9, p10); |
takuo | 1:8fb0961c0dc8 | 15 | STTS751 temp(p9, p10); |
takuo | 0:de38b1558115 | 16 | |
takuo | 0:de38b1558115 | 17 | // You can specify an I2C object instead. |
takuo | 0:de38b1558115 | 18 | // I2C i2c(p9, p10); |
takuo | 0:de38b1558115 | 19 | // ACM1602NI lcd(i2c); |
takuo | 0:de38b1558115 | 20 | // STTS751 temp(i2c); |
takuo | 0:de38b1558115 | 21 | |
takuo | 0:de38b1558115 | 22 | int main() { |
takuo | 0:de38b1558115 | 23 | while (true) { |
takuo | 0:de38b1558115 | 24 | lcd.locate(0, 0); |
takuo | 0:de38b1558115 | 25 | lcd.printf("temp: %.3f", (float)temp); |
takuo | 0:de38b1558115 | 26 | wait(1); |
takuo | 0:de38b1558115 | 27 | } |
takuo | 0:de38b1558115 | 28 | } |