Multiplexing and I2C

Hello
I am currently building a MIDI controller and I have written the code for its various parts separately.
The controller has 23 buttons, 11 potentiometers, two encoders, one I2C LCD screen 16x2 and a 2x2 trellix matrix from adafruit also I2C - here is the link :

https://learn.adafruit.com/assets/17311

I have attached a pic of the controller (and connections) which I have now assembled.
I am using an arduino leonardo, 4 CD4051 analogue multiplexers.

I have coded the separate parts of the project they work fine.
I have started to integrate all different bits of code and now I have a properly functioning code for all my potentiometers, buttons and encoders.
However when I add the codes for the I2C devices all the buttons and pots attached to the multiplexer dont work anymore (or don't work as expected, ie i get readings for 4 pot when moving one).
I can provide more info if needed.

I would really appreciate some help!

Please post a proper schematic. Hand drawn is ok, and 100 times better than what you just posted, which, frankly, looks like nonsense. Your pots are connected to your digital inputs and your buttons are connected to your analog inputs? Please review and correct.

Please see the attached file with proper schematics. Pots are connected to A0, A1 and A2. The pots on the multiplexers are read on Pin A3. Buttons are all connected to the multiplexers and the values are read on pin 5, 6 and 7.
Clearly all buttons are also connected to ground and pots 1 to 8 also connected to ground and 5v.

I hope it makes more sense now.

(sorry I just realised I made a mistake when drawing the schematics (the SCL and SDA are inverted )


Ok, that makes much more sense now, thankyou.

I can't see any reason for the symptoms you described in your original post, looking at that schematic. Please post your complete code. Use code tags.

Wait, I have it.

I am using an arduino leonardo

On Leonardo, SCA and SCL are pins 2, 3. You are using those to control the 4051s. (The SDA and SCL pins are connected on the Leonardo board to pins 2, 3.)

Use two other pins to control the 4051s, such as pins 10, 11.

thank you! for some reason I thought they were A4 and A5 !
Tomorrow I will try this and let you know !!
cheers!!

fluxia:
for some reason I thought they were A4 and A5 !

They are, on Uno. Uno and Leonardo have different chips.

Bingo! Everything works well now together and yes when I was prototyping the project I was using an arduino uno on pin A4 and A5 .....
thank you very much!!