ArduinoでLCDディスプレイをI2Cで使う
LCDディスプレイをArduinoで使います。通信はI2Cの4ピンタイプなので、5V→5V、GND→GND、SDA→A4、SCL→A5に繋ぎます。ライブラリはこれ。I2Cのアドレスがわからない場合には、I2CScannerを使う。これは、Scannerで39なので進数変換器で16進数に変換すると、27になるので0x27をアドレスに使う。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display | |
void setup() | |
{ | |
lcd.init(); // initialize the lcd | |
// Print a message to the LCD. | |
lcd.backlight(); | |
lcd.setCursor(0, 0); | |
lcd.print("2018/3/19"); | |
lcd.setCursor(0, 1); | |
lcd.print("Arduino!"); | |
delay(3000); | |
lcd.clear(); | |
delay(3000); | |
lcd.noBacklight(); | |
} | |
void loop() | |
{ | |
} |
Post a Comment