STM32F103C8のMbedでの液晶,AQM0802Aで「A」を表示


1.SCLとSDAを接続、プルアップも忘れずに
2.電源の接続
3.下記のソースコードを書き込む
4.コンパイル実行で表示されたら終了
5.おわり



#include "mbed.h"

#define ADDR     (0x7C) //  address

//I2C i2c(I2C_SDA, I2C_SCL);
I2C i2c(PB_7, PB_6);

//DigitalOut myled(LED1);

//Serial pc(SERIAL_TX, SERIAL_RX);

//volatile char TempCelsiusDisplay[] = "+abc.d C";

int main()
{

    char data_read[2];

    //init
    wait(0.2);

    data_read[0] = 0x0;

    data_read[1]=0x38;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x39;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x14;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x70;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x56;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x6C;
    i2c.write(ADDR, data_read, 2);

    wait(0.2);

    data_read[1]=0x38;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x0C;
    i2c.write(ADDR, data_read, 2);

    data_read[1]=0x01;
    i2c.write(ADDR, data_read, 2);

    wait(0.2);

    data_read[0]='@';
    data_read[1]='a';
    i2c.write(ADDR, data_read, 2);


    while (1) {

        // Display result
//        pc.printf("temp = %s\n", TempCelsiusDisplay);
//        myled = !myled;
        wait(2.0);

    }

}