Need help wiring a button box

These chips can use the same SCL/SDA, up to 8 of them. ( 8 X 16 = 128 )

Vss is the GND pin.

The same GND can be used for the switches.

The rotary encoder outputs go to 2 (two) of the inputs.

When you say the rotary encoder outputs go to 2 inputs, the pins on the chip can act as both an input or output correct?

And forgot to ask, but do you just wire the chip into 2 inputs on the microcontroller? As I don't believe there are SCL or SDA pins on it. Otherwise how would they use the same SCL/SDA? Would it just be wire all of them to the same 2 wires that connect to the microcontroller?

When you say the rotary encoder outputs go to 2 inputs, the pins on the chip can act as both an input or output correct?

Yes

And forgot to ask, but do you just wire the chip into 2 inputs on the microcontroller? As I don't believe there are SCL or SDA pins on it.

A5 = SCL A4 = SDA (UNO)

Otherwise how would they use the same SCL/SDA?

Parallel the pins.

Would it just be wire all of them to the same 2 wires that connect to the microcontroller?

A4 and A5

How the I2C bus works.

On an Uno, the pins A4 (SDA) and A5 (SCL) are the I2C pins.

Each switch would have an input on the MCP23017 chips.

Each pin on the MCP32017 can be set as an input or an output. If a pin is set as an input it can have an internal pullup enabled. Here is an Adafruit tutorial for the MCP230xx chips.

I would not connect the rotary encoders to the MCP chip, but to their own pins on the Arduino. Programming will be easier that way as you can use the Encoder library. The Encoder library will not work with the MCP chips.

Yes, that’s a good suggestion.

What so you mean by this?

BTW

A 74HC165 is less expensive.

Has 8 inputs though.

Use SPI rather than I2C

74HC165_pinouts

SDA on the Arduino goes to all the SDA pins on the MCP23017s.

SCL on the Arduino goes to all the SCL pins on the MCP23017s.

And SPI is what? Sorry, don't know a whole lot about this stuff.

SPI = Serial Peripheral Interface.
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all

Very easy to use.
You can daisy chain 100s of the 74HC165 together.

Uses pins 10 (CS), 12 (MISO), and 13 (SCK) on the Arduino.

Okay so its another style chip with fewer inputs but less expensive and uses pins 10, 12, and 13 on the Arduino. What do those three wires connect to on the chip (which pins)?

74HC165_pinouts

Arduino pin 10 to 74HC165 pin 1

Arduino pin 13 to 74HC165 pin 2

Arduino pin 12 to 74HC165 pin 9

And would resistors, diodes or capacitors be required for any of these chips or anywhere in the circuit?


The resistors are pull-downs for each switch.

The capacitors are for power supply decoupling, all ICs need them.

Please read this:


Oops the link has been corrected.


BTW
The 74HC165 are for inputs only.

The 74HC595 are for outputs.

Instead of having to write long answers, could you tell or show me where the resistor and capictor would be placed in the circuit (just one example for each. I dont know what an IC is or a pull down.

Do these methods worl for both Uno and pro Micro, or just one?

The 74HC165 can work with all controllers.


3V3 would change to 5V for the UNO.

Change D5 to D10.



image

The above shows wiring 2 (two) 74HC165s together.

D9 change to D10

Okay thanks for all your help! I might have a few more questions, but its late so I will save them for tomorrow.

Is this anything close to being correct? There is no pin 12 and 13 on a pro micro (as I can't use an UNO as it doesn't support the joystick library) so I left those wires out. Obviously I would still have to add more chips with the rest of the buttons. I also didn't find a place for the resistors or capacitors. I think I'm a little lost at this point.

A LOW indicates that switch is CLOSED.

This diagram is of much help. Thank you.

I do notice that it says 16 switches, however I only count 12 as 2 lines come to an end on each chip (D3 and D7).
As well when connecting a 3 prong switch, since the switch would already be connected to ground, one prong would go unused correct?
And for a 6 prong switch or a switch with a LED, it would take up 2 inputs instead of one correct?