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 3 years have passed since last update.

ArduinoのI2Cを使い、マイコン応用I2C液晶で文字表示して遊ぶ

Last updated at Posted at 2022-04-14

x 原因は、わからないが液晶がちらつく場合は、ウェートを調整してね!!

目的
I2C液晶のテスト

-317

o_con317.jpg

-318

o_con318.jpg

-319

o_con319.jpg

-184

o_con184.jpg

-185

o_con185.jpg

-361

o_con361.jpg

STM32G031とI2Cスレーブでマスターから送信された文字を液晶に表示(ACM1602K-NLW-BBW)

プログラム




//I2C_LCD_NS_test_UNO_1

#include <Arduino.h>
#include <Wire.h>

//LCD初期化関数
#define lcd_begin(aaa,bbb) Wire.begin()

//画面クリア
#define lcd_clear() for(int ii = 0;ii< 32;ii++){seg1(ii);seg1(' ');}

//カーソルの移動
#define lcd_setCursor(col,rows) seg1((rows * 0x10)+col) 

//液晶に一文字送信する
void seg1(char ch)
{
  //I2Cに送信
  Wire.beginTransmission(0x40);
  Wire.write(ch);
  Wire.endTransmission();
  delay(50);//1mS待つ 連続送信防止用 受信落ち対策
}//seg1

//文字列の表示
void lcd_print(char *str1)
{
  //文字の中身がゼロか
  while(*str1) {
    //一文字出力
    seg1(*str1 ++);
  } //while
}//print


//初期化
void setup()
{
  lcd_begin(16, 2);
  delay(3500);

  lcd_clear();

  //文字列の表示
  lcd_setCursor(0, 0);
  lcd_print("HELLO WORLD");

} //setup

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


コメントなしプログラム




//I2C_LCD_NS_test_UNO_2
#include <Arduino.h>
#include <Wire.h>
#define lcd_begin(aaa,bbb) Wire.begin()
#define lcd_clear() for(int ii = 0;ii< 32;ii++){seg1(ii);seg1(' ');}
#define lcd_setCursor(col,rows) seg1((rows * 0x10)+col) 

void seg1(char ch){
  Wire.beginTransmission(0x40);
  Wire.write(ch);
  Wire.endTransmission();
  delay(50);
}

void lcd_print(char *str1){
  while(*str1){seg1(*str1 ++);}
}

void setup(){
  lcd_begin(16,2);
  delay(3500);
  lcd_clear();
  lcd_setCursor(0,0);
  lcd_print("HELLO WORLD");
}

void 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?