Analog inputs with different Midi Channels

Hello i´m new in the Arduino world. i want to build a midi controller with 162 encoders. Now i don´t know what to do. encoders are working well. but One midichannel has 128 cc´s. my question is : Can i give as example Analog input 0 the midichannel 1 and analog input 1 the midichannel 2 ?!?!
Is this possible !? Knows anyone a sketch for this?

many Thanks and Kind Regards,

Schimi

Can i give as example Analog input 0 the midichannel 1 and analog input 1 the midichannel 2 ?!?!
Is this possible !

Yes, you can do that.

Knows anyone a sketch for this?

The CC message header has the channel number as the four least significant bits.
So for midi channel 1 use 0xB0 and
for midi channel 2 use 0xB1 and
for midi channel 3 use 0xB2 and
for midi channel 4 use 0xB3 and ......
for midi channel 16 use 0xBF.

Follow this with the controller number and finally with the number you want to set the controller to.

Please read the how to use this form sticky post to learn how to post your code correctly using code tags. Please correct that last post.

That code will not compile do you know that? What code have YOU written.

Exactly what do you want is to do?

Note that 0xB0 is exactly the same as the 176 that you have only it is in hexadecimal form to make things easy.

hello mike,
how i can calculate or see which number is as example cc 65 on midi channel 2?

The message header for CC is 0xB0 or in decimal it is 176 for MIDI channel 1.

The message header for CC is 0xB1 or in decimal it is 177 for MIDI channel 2.

So for any MIDI channel n the message header is simply 0xB0 + (n-1) or 176 + (n-1)

To set CC 65 to a value of 127 on MIDI channel 2 send the bytes:-
177, 65 127
Out to the MIDI port.

oh man. i´m really stupid. i don´t understand.
How do I assign an encoder to a CC number and a MIDI channel.?
do you have maybe a "demo" sketch ?

am sorry that I steal your time.

How do I assign an encoder to a CC number and a MIDI channel.?

You don't.

You read a sensor lets say it is a pot with an analogue read.
You then make that number into the range of MIDI data, which is 0 to 127 by dividing it by 8.
You then send that number to any CC number on any MIDI channel you want.

do you have maybe a "demo" sketch ?

Not that does anything so simple as that.
I wrote this but I am worried you might get confused with everything round it.

// Sets CC number 52 to the value given by reading a pot on Analogue input 0
void setup() {
 Serial.begin(31250);       // MIDI speed
}

int lastReading;
void loop() {
  int newReading = analogRead(0); // read a pot on input 0
  if(abs(newReading-lastReading) > 6){
    lastReading = newReading; // save reading for next time
    midiSend(0,0xB0, 52, newReading / 8); // send to CC controller number 52, on channel 1, the value on the pot
  }
}

  //  send a MIDI message
 void midiSend(byte chanel,byte cmd, byte data1, byte data2) {
  cmd = cmd + chanel;  // merge channel number and message number
  Serial.write(cmd);
  Serial.write(data1);
  Serial.write(data2);
}

Do you actually understand what CC messages do?

thank you.