Arduino MIDI Controller Potentiometers not Functioning

I am trying to make an Arduino UNO based MIDI controller. I am using loopMIDI and HairlessMIDI to convert the USB serial signals to MIDI signals which are being sent into FL studio. I am trying to set up 5 potentiometers to send MIDI control signals. I am also trying to have an I2C LCD display the values of each pot. There aren’t enough analog ports on an Arduino UNO for this so I am using a multiplexer for 4/5 of the pots. I have gotten all of the pots to send the proper output to the serial monitor, but they will not send MIDI signals properly (there is a constant stream of MIDI signals with seemingly random values) and the LCD is having trouble (Freezing until randomly flashing a ton and updating or freezing until the pot that isn’t attached to the multiplexer is moved in which case it will update).

My Code is mostly taken from online but I have edited it. If there is any other necessary information I would be happy to provide it.

I am new at this.

Thank You!!

MIDI_Controller_with_multiplexer.ino (21.1 KB)

Your code reads the pots through the multiplexer on A2 and the slider on A0 but it only uses those values for the LCD display. The code you started with reads A0 through A5 and sends THOSE as control changes. I’m guessing that the other analog inputs aren’t connected and, therefore, floating.

Try this experiment: Connect A1, A3, A4, and A5 to Ground. Then your MIDI output should be stable. The lowest control channel will be your Slider (A0) and the third will be whatever pot is selected in the multiplexer (A2). The other four will be zeroes (Ground).