Problem with sending MIDI CC messages

write()

Writes binary data to the serial port. This data is sent as a byte or series of bytes

Your MIDI function expects three byte values as parameters and you are passing three (signed) ints. Maybe the language has some clever type conversion, but why not declare them that way in the first place, rather than relying on implicit conversion or explicit casts?

byte AnalogValue[6] = {0,0,0,0,0,0}; // define variables for the controller data
byte lastAnalogValue[6] = {0,0,0,0,0,0}; // define the "lastValue" variables
byte midiCCselect[6] = {22,23,24,25,26,27}; // select the midi Controller Number for each input (22 to 31 are free)

Also, there should be a 220R resistor in series between your digital out and pin 5 of the MIDI socket.