Using the Unit MIDI ・ 使用 Unit MIDI
M5StackのUnit MIDIをコントローラーに接続する最小構成。配線とBOMつき。
この構成をエディタで開く・編集する →| 部品 | 役割 | ポート | リンク・価格 |
|---|---|---|---|
| ATOM Lite | Controller | grove_i2c, i2c, gpio | official page — $7.5 |
| Unit MIDI | unit | grove_uart, gpio, audio_jack | official page — $14.5 |
ATOM LiteとUnit MIDIで作る、かんたんなMIDI音源モジュールです。Unit MIDIは5ピンDIN端子と3.5mmヘッドホンジャックを備え、MIDI信号を音声に変換します。ATOM LiteからUART経由でMIDIコマンドを送信すると、Unit MIDIが音を鳴らします。
# M5Stack ATOM Lite + Unit MIDI
# Wiring: Unit MIDI -> ATOM Lite Grove Port.C (UART)
# ATOM Lite sends MIDI note messages via UART
import time
from machine import UART, Pin
# Initialize UART on Port.C (TX=GPIO26, RX=GPIO32)
uart = UART(1, baudrate=31250, tx=26, rx=32)
# MIDI helper functions
def note_on(note=60, velocity=127, channel=0):
uart.write(bytes([0x90 | channel, note, velocity]))
def note_off(note=60, velocity=0, channel=0):
uart.write(bytes([0x80 | channel, note, velocity]))
# Main loop: play a C major scale
notes = [60, 62, 64, 65, 67, 69, 71, 72] # C4 to C5
while True:
for n in notes:
note_on(n)
time.sleep(0.2)
note_off(n)
time.sleep(0.1)
time.sleep(1)
この作り方はAIが構成から生成したものです(未検証)。通電前に配線とコードをご確認ください。
この構成はAIが実在するM5Stack部品から設計し、ポート互換をサーバで検証したものです。編集・共有できます。
エディタで開く →UnitKit は M5Stack® 製品向けの非公式ツール。作りたいものを書くと、部品リストと配線図が出ます。