Arduino Midi Device + Multiplexer

Thread Starter

JustMe234

Joined Feb 25, 2017
68
How to read from another multiplexer in this code. I have try to add another analogRead and return that value but doesn't work.
I have upload a schematic of wiring.

Here is the Code
Code:
void loop()
{
  //Loop through all mux channels
  for (byte muxChannel = 0; muxChannel < MUX_NUM_CHANNELS; ++muxChannel)
  {
    int midiValue = multiMap(readMuxChannel(muxChannel), sliderFromMap, sliderFromMapSize, sliderToMap, sliderToMapSize);

    if (ccValue[muxChannel] != midiValue)
    {
      ccValue[muxChannel] = midiValue;
      midiControlChange(MIDI_CHANNEL, MIDI_CC_START + muxChannel, midiValue);
    }
  }

//Reads analog value of mux chip at selected channel
int readMuxChannel(byte channel)
{
  //Select mux channel
  digitalWrite(MUX_ADDRESS_SEL_0, channel & 1);
  digitalWrite(MUX_ADDRESS_SEL_1, (channel >> 1) & 1);
  digitalWrite(MUX_ADDRESS_SEL_2, (channel >> 2) & 1);

  //Read mux output
  return analogRead(MUX_COM);
}
 

Attachments

Last edited:
Top