I2C 接続の温度センサ ADT7410 用のライブラリの使用例. Demo program of the library for temperature sensor ADT7410 connected using I2C interface.
Dependencies: mbed UIT_ADT7410
Diff: main.cpp
- Revision:
- 0:4987fb36ca61
- Child:
- 1:639e2ad4ab5e
diff -r 000000000000 -r 4987fb36ca61 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 15 05:46:14 2015 +0000 @@ -0,0 +1,51 @@ +//-------------------------------------------------------------- +// ADT7410 and LCD display using I2C interface +// 2015/06/15, Copyright (c) 2015 MIKAMI, Naoki +//-------------------------------------------------------------- + +#include "ADT7410.hpp" + +// If you want to display the temperature on AQM1602, +// enable following #define statement +//#define USING_AQM1602 + +#ifdef USING_AQM1602 +#include "AQM1602.hpp" +#endif + +using namespace Mikami; + +#ifdef USING_AQM1602 +Aqm1602 lcd_; // using default port +#endif +ADT7410 tempr_; // using default + +int main() +{ + printf("\r\nStart ADT7410\r\n"); +#ifdef USING_AQM1602 + lcd_.WriteStringXY("ADT7410", 0, 0); +#endif + + tempr_.SetConfig(0x80); // 16-bit mode + + // Confirmation of setting + uint8_t cReg = tempr_.GetConfig(); + printf("Mode: 0x%02x\r\n", cReg); + + while (true) + { + float tempr = tempr_.Get(); + +#ifdef USING_AQM1602 + char str[8]; + sprintf(str, "%5.1f ", tempr); + string s1 = (string)str + (char)0xDF + "C"; + lcd_.WriteStringXY(s1, 0, 1); +#else + printf("%5.1f deg. Celsius\r\n", tempr); +#endif + wait(1); + } +} +