this is an example of midi out with an led matrix and capacitive touch

   
import adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_off import NoteOff
from adafruit_midi.midi_message import MIDIUnknownEvent
import analogio
import time
import busio
import adafruit_mpr121
from adafruit_debouncer import Debouncer
import board
import adafruit_ht16k33.segments
import adafruit_ht16k33.matrix 

i2c = busio.I2C(board.SCL, board.SDA)
mpr121 = adafruit_mpr121.MPR121(i2c)
matrix = adafruit_ht16k33.matrix.Matrix16x8(i2c)

uart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0.001)  # init UART

matrix.fill(1)
time.sleep(1)
matrix.fill(0)
matrix[0, 0] = 1

# Clear the matrix.
matrix.fill(0)

# Set a pixel in the origin 0, 0 position.
matrix[0, 0] = 1
# Set a pixel in the middle 8, 4 position.
matrix[8, 4] = 1
# Set a pixel in the opposite 15, 7 position.
matrix[15, 7] = 1

time.sleep(2)

# Draw a Smiley Face
matrix.fill(0)

for row in range(2, 6):
    matrix[row, 0] = 1
    matrix[row, 7] = 1

for column in range(2, 6):
    matrix[0, column] = 1
    matrix[7, column] = 1

matrix[1, 1] = 1
matrix[1, 6] = 1
matrix[6, 1] = 1
matrix[6, 6] = 1
matrix[2, 5] = 1
matrix[5, 5] = 1
matrix[2, 3] = 1
matrix[5, 3] = 1
matrix[3, 2] = 1
matrix[4, 2] = 1


#midi for garden listener on channel 2
garden_in_channel = 1
garden_out_channel = 2
garden = adafruit_midi.MIDI(
     midi_in=uart,
     midi_out=uart,
     in_channel=(garden_in_channel - 1),
     out_channel=(garden_out_channel - 1),
     debug=False,
 )

#midi out only
midi_out_channel = 1
midi = adafruit_midi.MIDI(
     midi_out=uart,
     out_channel=(midi_out_channel - 1),
     debug=False,
 )

#set up USB midi if necessary
# print(usb_midi.ports)
# midi = adafruit_midi.MIDI(
#     midi_in=usb_midi.ports[0], in_channel=0, midi_out=usb_midi.ports[1], out_channel=0
# )

#  midi note numbers
midi_notes = [60, 64, 67, 72, 77, 85, 90, 95, 30, 41, 45, 50]

keys = []

for i in range(12):
    keys.append(mpr121[i])

#  states for buttons
key0_pressed = False
key1_pressed = False
key2_pressed = False
key3_pressed = False
key4_pressed = False
key5_pressed = False
key6_pressed = False
key7_pressed = False
key8_pressed = False
key9_pressed = False
key10_pressed = False
key11_pressed = False

#  array for button states
key_states = [key0_pressed, key1_pressed, key2_pressed, key3_pressed,
    key4_pressed, key5_pressed, key6_pressed, key7_pressed,
    key8_pressed, key9_pressed, key10_pressed, key11_pressed]

while True:
    # #listen to garden listener
    # msg_in = garden.receive()  # non-blocking read
    #     #For a Note On or Note Off play a major chord
    #     #For any other known event just forward it
    # if isinstance(msg_in, NoteOn) or isinstance(msg_in, NoteOff):
    #    garden.send(msg_in)
    #    print("sent")

    # elif isinstance(msg_in, MIDIUnknownEvent):
    #     # Message are only known if they are imported
    #     print("Unknown MIDI event status ", msg_in.status)

    # elif msg_in is not None:
    #     garden.send(msg_in)
    #     print("sent")
    #    #  iterate through 12 pads
    for i in range(12):
        inputs = keys[i]
        #  if button is pressed...
        if inputs.value and key_states[i] is False:
            #  update button state
            key_states[i] = True
            #  send NoteOn for corresponding MIDI note
            midi.send(NoteOn(midi_notes[i], 120))
            #  print(str(inputs.value) +" "+ str(key_states[i]))
            print("play key " +str(i)+" & note "+str(midi_notes[i]))
            for frame in range(0, 8):
                matrix.shift_up(True)

        #  if the button is released...
        if not inputs.value and key_states[i] is True:
            #  send NoteOff for corresponding MIDI note
            midi.send(NoteOff(midi_notes[i], 120))
            key_states[i] = False  
            #  print(str(inputs.value) +" "+ str(key_states[i]))
            print("stop key " +str(i)+" & note "+str(midi_notes[i]))
            for frame in range(0, 8):
                matrix.shift_right(True)