Using the Step16 Unit (Unit Step16) with 16-bit Rotary Encoder ・ 使用 Step16 Unit (Unit Step16) with 16-bit Rotary Encoder
M5StackのStep16 Unit (Unit Step16) with 16-bit Rotary Encoderをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| ATOM Lite | Controller | grove_i2c, i2c, gpio | official page — $7.5 |
| Step16 Unit (Unit Step16) with 16-bit Rotary Encoder | unit | grove_i2c | official page |
ATOM LiteとStep16 Unit(16ビットロータリーエンコーダ)をI2Cで接続し、エンコーダの値を読み取る最小構成の組み立てガイドです。エンコーダのつまみを回すと、0〜Fの16段階の値がATOM Liteで読み取れます。
# ATOM Lite + Step16 Unit (16-bit Rotary Encoder)
# Wiring: Step16 Unit -> ATOM Lite Grove Port (I2C, red Port.A)
# I2C address: 0x48 (default)
from machine import Pin, I2C
import time
# Initialize I2C on ATOM Lite (SDA=26, SCL=32)
i2c = I2C(0, scl=Pin(32), sda=Pin(26), freq=100000)
# Step16 Unit I2C address
STEP16_ADDR = 0x48
# Register to read encoder value (0x00 = current position)
REG_POSITION = 0x00
def read_encoder():
try:
data = i2c.readfrom_mem(STEP16_ADDR, REG_POSITION, 1)
return data[0] & 0x0F # lower 4 bits = position 0-15
except OSError:
return None
while True:
pos = read_encoder()
if pos is not None:
print("Encoder position: {}".format(pos))
else:
print("Error reading encoder")
time.sleep(0.2)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。