Devices & Components
10 jumper wires 150mm male
Arduino MKR WiFi 1010
Colorful Round Tactile Button Switch
Hardware & Tools
VMPK
Software & Tools
Arduino IDE
Project description
Code
write-to-device.py
python
Write MIDI note n°60 ON and OFF to USB device
1#!/usr/bin/env python3 2 3# ~~~ write-to-device.py ~~~ 4 5import mido # pip install mido 6import time 7 8if __name__ == "__main__": 9 # get the list of all the MIDI devices conneted 10 input_names = mido.get_input_names() 11 12 # choose the name of the USB MIDI device 13 # you want to send messages to 14 usb_midi_device_name = input_names[1] 15 16 try: 17 # open the selected MIDI output port 18 with mido.open_output(usb_midi_device_name) as port: 19 print(f"Sending MIDI messages to {usb_midi_device_name}") 20 21 # send Note On message 22 note_on = mido.Message('note_on', note=60, velocity=64, channel=0) 23 port.send(note_on) 24 print(f"Note On sent: {note_on}") 25 26 # wait for a short duration 27 time.sleep(1) 28 29 # send Note Off message 30 note_off = mido.Message('note_off', note=60, velocity=64, channel=0) 31 port.send(note_off) 32 print(f"Note Off sent: {note_off}") 33 34 except KeyboardInterrupt: 35 print("Exiting...")
read-MIDI-device.py
python
Read from MIDI device.
1#!/usr/bin/env python3 2 3# ~~~ read-MIDI-device.py ~~~ 4 5import mido 6 7if __name__ == "__main__": 8 # list available MIDI ports 9 input_names = mido.get_input_names() 10 print(">>> available MIDI ports:") 11 print(input_names) 12 13 # select desired port 14 # i.e. "Arduino MKR WiFi 1010:Arduino MKR WiFi 1010 MIDI 1 20:0" 15 input_port_name = input_names[1] 16 inport = mido.open_input(input_port_name) 17 18 # loop to receive messages 19 while True: 20 for message in inport.iter_pending(): 21 print(message)
Downloadable files
Project Schematic
Project Schematic with Arduino MKR WiFi-1010
piano-keyboard.png

Documentation
MIDIUSB
Allows Arduino act as a MIDI instrument over USB.
https://github.com/arduino-libraries/MIDIUSB
mido
Working with MIDI messages and ports.
https://github.com/mido/mido
Comments
Only logged in users can leave comments