0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

STM32G071で「HELLO」と液晶表示(AQM0802A)(NUCLEO-G071RB)

Posted at

x NUCLEO-G071RB

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

o_con794.jpg




#include <Wire.h> //I2C library

// I2C  address. 
#define I2Cadr  0x3e  // 固定

char    data_read[2]={'@','t'}; //i2cバッファー
int     ii;                     //ループカウンター

//液晶初期化配列
char INIT_com[]={0x0,0x38,
0x0,0x39,
0x0,0x4,
0x0,0x14,
0x0,0x70,
0x0,0x56,
0x0,0x6C,
0x0,0x38,
0x0,0xC,
0x0,0x1,
0x40,0x41};

//オールクリア
char INIT_cls[]={0x0,0x1};

//I2Cに2文字送る
void i2c_led_w(char *buff1){
  Wire.beginTransmission(I2Cadr);
  Wire.write(buff1[0]);
  Wire.write(buff1[1]);
  Wire.endTransmission();
  delay(2);
}//i2c_led_w


//初期化
void setup() {

  //i2cの初期化
  Wire.begin(); // initialise the connection //767 UNO 071

  //液晶の初期化
  for(ii=0;ii<11;ii++){
    i2c_led_w(&INIT_com[ii*2]);
  } //for

}//setup


//メインループ
void loop() {

  //画面のクリア
  i2c_led_w(INIT_cls);

  //HELLOを表示
  char dat[]="HELLO";
  ii=0;
  while(dat[ii] != 0){
    
    //制御文字'@'と表示文字1文字を液晶に送る
    data_read[1]=dat[ii];
    i2c_led_w(data_read);
    ii++;

  }//while

  delay(1000); //1秒待つ

}//loop




0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?