Midi Shield - Sending Sysex

Sending MIDI is relatively straightforward, filtering the analog input and only sending MIDI messages when you're actually turning the knob could be a bit more involved.

You could use the Control Surface library I maintain, it supports many different MIDI interfaces and has functions for filtering analog inputs built-in, so you don't have to reinvent the wheel there.

You could do something like this, for example:

#include <Control_Surface.h> // https://github.com/tttapa/Control-Surface

// MIDI interface on “Serial” UART (TX/RX pins)
HardwareSerialMIDI_Interface midi { Serial };

// Reads, filters and detects changes of an analog input
// Produces a 7-bit output [0-127]
FilteredAnalog<7> potentiometer { A0 }; 

// MIDI System Exclusive data to send
uint8_t sysex_data[] {
  0xF0, 0x41, 0x36, 0x00, 0x23, 0x20, 0x01, 0x10, 0x00, 0xF7,
};
// Reference to easily update the parameter value of the SysEx message
uint8_t &vcf_value = sysex_data[8];

void setup() {
  // Initialize MIDI interface and analog input
  midi.begin();
  potentiometer.setupADC();
}

void loop() {
  midi.update(); // Handle and discard MIDI input

  // Check whether the potentiometer value changed
  if (potentiometer.update()) {
    vcf_value = potentiometer.getValue(); // if it did, update the message
    SysExMessage msg { sysex_data, sizeof(sysex_data) };
    midi.send(msg); // and send it out over MIDI
  }
}

Pieter