tttapa / MIDI_controller

This is a library for creating a MIDI controller using an Arduino or Teensy board.
GNU General Public License v3.0
404 stars 69 forks source link

Connecting multiple multiplexers to analog inputs for micro #95

Closed Shuvam1997 closed 5 years ago

Shuvam1997 commented 5 years ago

I love the code and it works perfectly for a single multiplexer... However, I need to use 4 multiplexers and 32 knobs attached to them for my project and I tried several combinations to do this...

It shows the following error

Screenshot_3

The code I typed had the modifications as below: AnalogMultiplex multiplexer[] = { {A0, {10, 16, 14}}, {A1, {10, 16, 14}},};

tttapa commented 5 years ago

You declared it as an array, so you have to access the array element first, before calling the .pin method on it.

You could try something like this:

AnalogMultiplex multiplexers[] = {
  {A0, {10, 11, 12, 13}},
  {A1, {10, 11, 12, 13}},
  {A2, {10, 11, 12, 13}},
  // ...
};

Analog potentiometers[] = {
  { multiplexers[0].pin(0), 0x1, 1 },
  { multiplexers[0].pin(1), 0x2, 1 },
  { multiplexers[0].pin(2), 0x3, 1 },
  // ...
  { multiplexers[1].pin(0), 0x11, 1 },
  { multiplexers[1].pin(1), 0x12, 1 },
  // ...
  { multiplexers[2].pin(0), 0x21, 1 },
  // ...
};
Shuvam1997 commented 5 years ago

Wow dude, thanks a lot....it works great...

I am really new to the arduino IDE and all this and it means a lot to me that you replied so fast...

On Sat, 24 Aug 2019, 21:39 tttapa, notifications@github.com wrote:

You declared it as an array, so you have to access the array element first, before calling the .pin method on it.

You could try something like this:

AnalogMultiplex multiplexers[] = { {A0, {10, 11, 12, 13}}, {A1, {10, 11, 12, 13}}, {A2, {10, 11, 12, 13}}, // ... };

Analog potentiometers[] = { { multiplexers[0].pin(0), 0x1, 1 }, { multiplexers[0].pin(1), 0x2, 1 }, { multiplexers[0].pin(2), 0x3, 1 }, // ... { multiplexers[1].pin(0), 0x11, 1 }, { multiplexers[1].pin(1), 0x12, 1 }, // ... { multiplexers[2].pin(0), 0x21, 1 }, // ... };

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/tttapa/MIDI_controller/issues/95?email_source=notifications&email_token=AMCXQZPDEFQPMRZITNM3WLTQGFML3A5CNFSM4IPGHJ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5CC7CY#issuecomment-524562315, or mute the thread https://github.com/notifications/unsubscribe-auth/AMCXQZMYYD2BTGZGSQNEIALQGFML3ANCNFSM4IPGHJ5Q .