Nucleo F401RE で使える I2C 接続の LCD ACM1602Ni 用のライブラリの使用例. Demo program of library for LCD ACM1602Ni connected using I2C interface on Nucleo F401.

Dependencies:   UIT_ACM1602NI mbed

main.cpp

Committer:
MikamiUitOpen
Date:
2015-07-06
Revision:
0:132eb47d57fb
Child:
1:d5e9bd9b38ad

File content as of revision 0:132eb47d57fb:

//------------------------------------------------------------
// Demo program for LCD ACM1602NI using I2C interface
//      Pullup resistors for SDA and SCL: 4.7 kΩ
// 2015/04/16, Copyright (c) 2015 MIKAMI, Naoki
//------------------------------------------------------------

#include "ACM1602NI.hpp"
using namespace Mikami;

Acm1602Ni lcd_;                               // Default, OK
//Acm1602Ni lcd_(D14, D15);                     // OK
//Acm1602Ni lcd_(D14, D15, 200000);             // OK
//Acm1602Ni lcd_(D14, D15, 200000, true, true); // OK
//Acm1602Ni lcd_(PB_3, PB_10);                  // OK
//Acm1602Ni lcd_(PC_9, PA_8);                   // OK
//Acm1602Ni lcd_(PB_4, PA_8);                   // OK 

Ticker timer_;

// Display elapsed time in minutes and seconds
void TimerIsr()
{
    static int k = 0;
    int sec = k % 60;   // seconds
    int min = k / 60;   // minits
    char str[20];
    sprintf(str, "%d'%2d\"", min, sec);
    lcd_.WriteStringXY(str, 0, 1);
    k++;
}

int main()
{
    if (lcd_.IsConnected()) printf("\r\nConnected");
    else                    printf("\r\nDisconnected");

    lcd_.WriteString("Hello World!");

    TimerIsr();
    timer_.attach(&TimerIsr, 1);

    while (true) {}
}