Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
BLEMIDI-Adapter.ino

BLEMIDI-Adapter

Turns an Arduino into a Bluetooth Low Energy (BLE) to 5-pin DIN MIDI adapter.

Boards: 🛈
Nano 33 IoT, Nano 33 BLE, ESP32, ESP32-S3, Pi Pico W

Configuration

Connections

See https://midi.org/specifications/midi-transports-specifications/5-pin-din-electrical-specs for the schematic, optocoupler models and resistor values.

Behavior

See also
MIDI over BLE
MIDI Tutorial

Written by PieterP, 2024-01-21
https://github.com/tttapa/Control-Surface

// Instantiate a MIDI over BLE interface
// Instantiate a 5-pin DIN MIDI interface (on the TX and RX pins of Serial1)
HardwareSerialMIDI_Interface midi_ser {Serial1};
// Instantiate the pipe to connect the two interfaces
void setup() {
// Change the name of the BLE device (must be done before initializing it)
midi_ble.setName("MIDI Adapter");
// Manually route MIDI input from the serial interface to the BLE interface,
// and the MIDI input from the BLE interface to the serial interface
midi_ser | pipes | midi_ble;
// Initialize the MIDI interfaces
// Initialize the built-in LED
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Continuously poll all interfaces and route the traffic between them
// Display the connection status using the built-in LED
digitalWrite(LED_BUILTIN, midi_ble.isConnected() ? HIGH : LOW);
}
constexpr PinStatus_t LOW
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
The main header file that includes all Control-Surface header files.
static void updateAll()
Update all enabled instances of this class.
static void beginAll()
Begin all enabled instances of this class.
bool isConnected() const
Returns true if a BLE central is currently connected.
void setName(const char *name)
Set the BLE device name.
A class for MIDI interfaces sending and receiving MIDI messages over a Hardware Serial port.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.
std::pair< MIDI_Pipe, MIDI_Pipe > BidirectionalMIDI_Pipe
A bidirectional pipe consists of two unidirectional pipes.
A class for MIDI interfaces sending MIDI messages over a Bluetooth Low Energy (BLE) connection.