-
Notifications
You must be signed in to change notification settings - Fork 13
I2C サンプルプログラム
Nishikori Koji edited this page Feb 24, 2022
·
11 revisions
教育ボードに搭載されている液晶ディスプレイ(LCD)とリアルタイムクロック(RTC)を使います。
基本的にESP-IDF環境と同じなので、ESP-IDF環境がインストールされているディレクトリ以下にプロジェクト用のディレクトリを作る。 GitHubからcloneする。
$ cd ~/esp
$ git clone https://github.com/gfd-dennou-club/iotex-esp32-mrubyc.git mrubyc-04-i2c
$ cd mrubyc-04-i2c
LCDに最初の10秒間"Hello! from ESP"と表示させ、その後に時刻を表示させるようにする。
サンプルプログラム
3行目
I2C 初期化
8行目
LCD 初期化
11行目以下
LCD に "Hello World" 表示
18行目
RTC 初期化. 時刻設定
24行目以下
時刻表示
mrblib/models/i2c.rbを以下のように書く
class I2C
def initialize(port, scl, sda)
@port = port
@scl = scl
@sda = sda
end
end
コンパイルと実行を行う。
$ make
$ make flash monitor