I2Cでディスプレイ接続

This text is also text!

準備


1
sudo i2cdetect -y 1
1
2
3
4
5
6
7
8
9
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

基本使い方


1
2
3
4
5
6
7
8
9
10
11
import board
from busio import I2C
from adafruit_ssd1306 import SSD1306_I2C

# I2Cオブジェクトを正しく初期化
i2c = I2C(scl=board.SCL, sda=board.SDA)

#
display = SSD1306_I2C(128, 64, i2c, addr=0x3C)
display.fill(1)
display.show()