12,966
回編集
126行目: | 126行目: | ||
以下にサンプルコードを記述する。<br> | 以下にサンプルコードを記述する。<br> | ||
<syntaxhighlight lang="c++"> | <syntaxhighlight lang="c++"> | ||
#include <Wire.h> // I2Cライブラリ | |||
#include <LiquidCrystal_I2C.h> | #include <LiquidCrystal_I2C.h> | ||
144行目: | 145行目: | ||
lcd.init(); | lcd.init(); | ||
lcd.backlight(); | lcd.backlight(); | ||
} | |||
void loop() | |||
{ | |||
lcd.setCursor(0, 0); // 1行目の先頭にカーソルを移動 | lcd.setCursor(0, 0); // 1行目の先頭にカーソルを移動 | ||
lcd.print("Hello,"); | lcd.print("Hello,"); | ||
lcd.setCursor(0, 1); // 2行目の先頭にカーソルを移動 | lcd.setCursor(0, 1); // 2行目の先頭にカーソルを移動 | ||
lcd.print("world!"); | lcd.print("world!"); | ||
delay(1000); | |||
lcd.clear(); // 表示をクリア | |||
delay(1000); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |