I've read through all of the MIDI examples that Adafruit has and tried my best to understand the "read the docs" information on midi, but I'm still not sure how to read a specific midi message over usb. I'm coming over to CircuitPython from Arduino, and trying to keep it as simple as possible here, but I'm having a hard time and am not finding it to be intuitive. In a nutshell, I just want to light up the neopixel on a KB2040 with a MIDI Control Change message and value. I've tried MANY different ways but need some help to bring this home. Hopefully someone can get the gist of what I'm trying to do from this bit of code I'm attempting to make work.
Code: Select all
import board
import busio
import usb_midi
import adafruit_midi
from adafruit_midi.control_change import ControlChange
import time
import neopixel
midi = adafruit_midi.MIDI(midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1], out_channel=0)
uart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0) # initialize UART
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
while True:
msg = midi.receive()
if msg is not None:
if isinstance(msg, ControlChange):
if msg.control = 41:
if msg.value = 127:
pixels.fill((255, 0, 0))
Kevin