In this Blog I would like to look into the options how we can connect a microcontroller with a Midi Keyboard. MIDI is a communication protocol from the 1980s that connects musical instruments and computers. MIDI keyboards nowadays usually have USB support and offer a separate MIDI port. Some modern keyboards even support Bluetooth.
To use either USB or a MIDI connector is usually quite challenging for a microcontroller. So the easiest is usually to connect the Keyboard to your computer and them the computer to the microcontroller:
Alternatives involving a Keyboard and a Separate Computer
In order to MIDI enable a micrcocontroller we have e.g. the following possibilities:
- Using a Serial Interface: Connect a MIDI keyboard to your PC and use an application to forward the signal to as USB Serial Adapter: The microcontroller is connected via the Serial interface. Or you can use a Raspberry PI which offers serial pins!
- Using Bluetooth – The ESP32 and ESP8266 processors support Bluetooth, so we can set up a serial communication over Bluetooth. You connect your Keyboard to the PC which then just forwards the communication w/o cable. Alternatively you can use a HC-05 Bluetooth Module.
- Using TCP/IP: The ESP32 and ESP8266 processors also support WIFI – so we can set up a network the communication. You connect your Keyboard to the PC which then just forwards the communication w/o cable.
- Using Bluetooth Low Energy: BLE. You connect your Keyboard to the PC which then just forwards the communication w/o cable.
Connecting your Keyboard directly to a Microcontroller
Fortunately we have some options that do not involve a separate computer:
- Connect a USB Host Module that implements MIDI to the microcontroller. With this we can connect a USB MIDI keyboard directly with a microcontroller.
- Use a MIDI Shield: You connect the keyboard with a MIDI cable to the shield – the communication to the microcontroller is via a serial cable.
- Some microcontrollers (e.g. the Raspberry Pico) support the implementation of multiple USB client devices and we can program these microcontrollers to behave like a MIDI Device.
I am planning to provide a detailed description for most of the described possibilities in my future posts…