Using the Unit Synth ・ 使用 Unit Synth
M5StackのUnit Synthをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| AtomS3 Lite | Controller | grove_i2c, gpio, usb_c | official page — $7.5 |
| Unit Synth | unit | grove_uart | official page — $12.95 |
AtomS3 LiteとUnit Synthで作る、かんたんなMIDIシンセサイザーです。AtomS3 Liteからシリアル通信でMIDI信号を送り、Unit Synthが音を鳴らします。
# M5Stack AtomS3 Lite + Unit Synth (MIDI synth)
# Wiring: Unit Synth -> AtomS3 Lite blue Port.C (UART)
import time
from machine import Pin, UART
# Port.C on AtomS3 Lite: UART on GPIO 1 (TX) and GPIO 2 (RX)
uart = UART(1, baudrate=31250, tx=1, rx=2) # MIDI standard baudrate
# Button on AtomS3 Lite: GPIO 41 (built-in button)
button = Pin(41, Pin.IN, Pin.PULL_UP)
note = 60 # Middle C
def play_note(note, velocity=100, channel=0):
note_on = 0x90 | channel
uart.write(bytes([note_on, note, velocity]))
time.sleep(0.2)
note_off = 0x80 | channel
uart.write(bytes([note_off, note, 0]))
print("Press the button to play notes!")
while True:
if button.value() == 0: # button pressed (active low)
play_note(note)
note += 1
if note > 84: # stop at high C
note = 60
time.sleep(0.3) # debounce
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。