I2C 接続の LCD AQM1602XA-RN-GBW 用のライブラリの使用例. Demo program of library for LCD 1602XA-RN-GBW connected using I2C interface.
Dependencies: mbed UIT_AQM1602
Diff: main.cpp
- Revision:
- 0:e1b05c7eb023
- Child:
- 1:6c838e71e330
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 05 06:45:13 2015 +0000 @@ -0,0 +1,51 @@ +//------------------------------------------------------------ +// Test program for LCD AQM1602XA-RN-GBW using I2C interface +// Pullup resistors for SDA and SCL: 10 kΩ +// 2015/05/30, Copyright (c) 2015 MIKAMI, Naoki +//------------------------------------------------------------ + +#include "mbed.h" +#include "AQM1602.hpp" +using namespace Mikami; + +Aqm1602 lcd_; // Default, OK +//Aqm1602 lcd_(D14, D15); // OK +//Aqm1602 lcd_(D14, D15, 200000); // OK +//Aqm1602 lcd_(D14, D15, 200000, true, true); // OK +//Aqm1602 lcd_(PB_3, PB_10); // OK +//Aqm1602 lcd_(PC_9, PA_8); // OK +//Aqm1602 lcd_(PB_4, PA_8); // OK + +Ticker timer_; +DigitalIn uButton_(USER_BUTTON); + +// Display 0, 1, 2, ..... +void TimerIsr() +{ + static int k = 0; + char str[10]; + sprintf(str, "%d", k++); + lcd_.WriteStringXY(str, 0, 1); +} + +void WaitButton() +{ + while (uButton_ == 1) {} + wait(0.2); +} + +int main() +{ + lcd_.Clear(); + lcd_.WriteString("Hello!"); + WaitButton(); // Waiting, push blue user button + lcd_.WriteStringXY("0123456789ABCDEF", 0, 0); + WaitButton(); // Waiting, push blue user button + lcd_.ClearLine(0); + WaitButton(); // Waiting, push blue user button + lcd_.WriteStringXY("AQM1602XA-RN-GBW", 0, 0); + TimerIsr(); + timer_.attach(&TimerIsr, 1); + + while (true) {} +}