Help with picking up best components

I am looking for a reccomendation of chips for my project which consists of:

31 LEDs (I need to run them on really low current, 5mA is more than enough)
46 pushbuttons
31 potentiometer
4 digital inputs coming from 2 rotary encoders (connected to LM324)

So at the moment I have a schematic which uses 6 4021 chips for buttons, 4+1 (4 slave/1 master) 4051 analogue multiplexer chips for reading the pots and 4 74HC595 chips for LEDs. Since the schematic is rather big I am looking for a way to minimise the amount of different chips here so I was thinking of using PCF8574 and I've already run a limitation - I can use 8 of chose chips which would give me a total of 64 digital I/O which is not enough if I'm going to connect 31 LED and 46 buttons on it. However it seems it's possible to multiplex the I2C bus (which I don't know nothing about so far) so that would solve the issue. So if I do that - is it going to draw too much current since each LED requires 5 miliamps? I'm open to (inexpensive) suggestions.

As original drawings build with 4 74HC595, there was no multiplexing of leds? You can minimize number of pins required for leds from 31 down to 8 + 4 = 12 using 4 transistor or ULN2803

The LEDs could all be driven by a single MAX7219 chip.

The buttons could be arranged in a matrix if you don't need multiple simultaneous button presses. That would mean you only need 16 I/O pins for the buttons.

14 pins for the push buttons - 7x7 matrix.
Could reduce to a Serial shift in also & use even less IO, and allow simultaneous button presses - have all 46 pulled high, with a diode each to cause an interrupt when a button was pressed & pulled the diode anode low, the cathode going to an interrupt pin. When the interrupt happens then latch the state of six 8-bit shift-in registers, shift th them in via SPI and act on the bits that represent button pushes.

Pots - can multiplex them all, or use four octal ADC chips accessed via SPI.

So now your IO is reduced to SPI:
SCK, MOSI, MISO to all devices
SS for MAX7219
4 SS for octal ADCs
1 SS for shift-in register string
1 INT for shift-in register string
Couple pins for each rotary encoder

14 total - within the range of an Uno/328P chip.
328P, MAX7219, 4 ADCs, 6 shift registers, 48 resistors, 48 diodes - easy to fit on a 1 page schematic.
Decoupling caps, crystal/caps, couple other Rs & Cs for support. Piece of cake.
Header pins for offboard LEDs, pots, rotary encoders, power.

fungus:
The LEDs could all be driven by a single MAX7219 chip.

Is this the correct one?

fungus:
The buttons could be arranged in a matrix if you don't need multiple simultaneous button presses. That would mean you only need 16 I/O pins for the buttons..

I need simultaneous presses so that's not an option.

CrossRoads:
14 pins for the push buttons - 7x7 matrix.
Could reduce to a Serial shift in also & use even less IO, and allow simultaneous button presses - have all 46 pulled high, with a diode each to cause an interrupt when a button was pressed & pulled the diode anode low, the cathode going to an interrupt pin. When the interrupt happens then latch the state of six 8-bit shift-in registers, shift th them in via SPI and act on the bits that represent button pushes.

This is too much to grasp for me. Do you have any schematic?

EDIT: So you're suggesting that I use 14 inputs into 4021 (using 2 of them obviously) with diode connected to every of those 14 inputs?

CrossRoads:
Pots - can multiplex them all, or use four octal ADC chips accessed via SPI.

Using what chip?

Just for the reference this is how my current PCB design looks like:

Link

Find a shift register that has an Output Enable line so you can disable it from driving the MISO line when other devices are talking.

Diode example - not until I get home.
Each input will have pullup resistor to +5, diode anode, and normally open switch.
Diode cathode connects other diode cathode, all cathodes connect to D2/INT0.
Switch closes, pulls anode low, cathode goes low and signals interrupt to the '328.
Interrupt code then toggles the Parallel input clock line to capture the state of the inputs.

Octal ADC, one example:
http://www.digikey.com/product-search/en/integrated-circuits-ics/data-acquisition-analog-to-digital-converters-adc/2556291?k=mcp3208

CrossRoads:
Find a shift register that has an Output Enable line so you can disable it from driving the MISO line when other devices are talking.

Diode example - not until I get home.
Each input will have pullup resistor to +5, diode anode, and normally open switch.
Diode cathode connects other diode cathode, all cathodes connect to D2/INT0.
Switch closes, pulls anode low, cathode goes low and signals interrupt to the '328.
Interrupt code then toggles the Parallel input clock line to capture the state of the inputs.

Octal ADC, one example:
http://www.digikey.com/product-search/en/integrated-circuits-ics/data-acquisition-analog-to-digital-converters-adc/2556291?k=mcp3208

So far I understand the part about ADC and MAX7219 for LEDs. Are you talking about interrupt pin on Arduino or? Because those 2 are already taken for rotary encoders... unless you have better idea.

PCINT for interrupts, available on almost all the pins

Scroll down about half way to

"Pin change interrupts"

Thanks for help. Do I need external power supply for MAX7219 btw?

Not for just 1 chip. I've run 4 from a Duemilanove with 9V supply. 12V supply overheated the regulator.
7.5V would be even better.
http://www.dipmicro.com/store/DCA-07510

kustom:

fungus:
The LEDs could all be driven by a single MAX7219 chip.

Is this the correct one?

Yep.

kustom:

fungus:
The buttons could be arranged in a matrix if you don't need multiple simultaneous button presses. That would mean you only need 16 I/O pins for the buttons..

I need simultaneous presses so that's not an option.

You can still do it, it just gets a little bit more complex. You need to add a diode to each switch, wire it up like the first image in this thread: http://arduino.cc/forum/index.php/topic,158691.0.html

ie.

fungus:
You can still do it, it just gets a little bit more complex. You need to add a diode to each switch, wire it up like the first image in this thread: http://arduino.cc/forum/index.php/topic,158691.0.html

ie.

That would mean I need 2 shift registers (4021?) to connect those 14 inputs? Or? Because CrossRoads said I need 6 shift registeres - that part is unclear to me.

kustom:
That would mean I need 2 shift registers (4021?) to connect those 14 inputs? Or? Because CrossRoads said I need 6 shift registeres - that part is unclear to me.

Two for the keyboard. The other 4 are for all the other hardware you want to attach.

fungus:

kustom:
That would mean I need 2 shift registers (4021?) to connect those 14 inputs? Or? Because CrossRoads said I need 6 shift registeres - that part is unclear to me.

Two for the keyboard. The other 4 are for all the other hardware you want to attach.

I don't get it. SCK, MOSI and MISO for MAX7219 and 4x mcp3208. SS for max and 4x mpc. That's 4 pins so far? 4 more for rotary encoders. 8 in total.

And then 3 pins for two 4021 (7x7 matrix). Why 6 shift registers? What am I missing here?

kustom:
I don't get it. SCK, MOSI and MISO for MAX7219 and 4x mcp3208. SS for max and 4x mpc. That's 4 pins so far? 4 more for rotary encoders. 8 in total.

And then 3 pins for two 4021 (7x7 matrix). Why 6 shift registers? What am I missing here?

What happened to your "31 potentiometers"?

I'm late coming to this thread, but I would use 7 x 5 multiplexing for the LEDs and 7 x 7 multiplexing for the switches. You can use the same column outputs for both the LED and the switches. See attached schematic (which only shows 4 LEDs and 4 buttons). This needs:

7 resistors (for the LEDs)
1 ULN2803 (or 6 x NPN transistors + base resistors)
46 x 1N4148 diode (or 7 x 8-way common anode diode networks)

For the 31 pots I suggest 4 x 74HC4051 multiplexers, to multiplex them into 4 analog inputs.

Total pin count:

7 column outputs
7 pushbutton inputs
5 LED outputs
3 digital outputs for driving the 74HC4051s
4 analog inputs

Total 26 pins so far, so no problem if you use a Mega. If you want to use a Uno, add a 74HC238 to generate 8 column outputs from 3 pins, and use those same 3 pins to drive the 74HC4051s. You then only need 6 pushbutton input pins (8 x 6 multiplexing) and 4 LED outputs (8 x 4 multiplexing). That reduces the requirement to 17 pins.

You've indicated that you want 4 pins for the rotary encoders. What sort of encoders are they, and why do you think you need op amps to interface them? If they are standard mechanical rotary encoders used as input devices, then you don't need any extra hardware, and you can also multiplex them using diodes. In that case, you could do the whole thing in 18 pins on a Uno, leaving the Tx and Rx pins free for debugging.

You could also multiplex the LEDs and the buttons on the same matrix, saving one of the I/O chips.

(the columns of the matrix could have LEDs and buttons attached)

fungus:

kustom:
I don't get it. SCK, MOSI and MISO for MAX7219 and 4x mcp3208. SS for max and 4x mpc. That's 4 pins so far? 4 more for rotary encoders. 8 in total.

And then 3 pins for two 4021 (7x7 matrix). Why 6 shift registers? What am I missing here?

What happened to your "31 potentiometers"?

Nothing happened. I've counted the MPC3208 (bold part).

dc42:
I'm late coming to this thread, but I would use 7 x 5 multiplexing for the LEDs and 7 x 7 multiplexing for the switches. You can use the same column outputs for both the LED and the switches. See attached schematic (which only shows 4 LEDs and 4 buttons). This needs:

7 resistors (for the LEDs)
1 ULN2803 (or 6 x NPN transistors + base resistors)
46 x 1N4148 diode (or 7 x 8-way common anode diode networks)

Would that allow simultaneous button presses + individual LED control?

dc42:
For the 31 pots I suggest 4 x 74HC4051 multiplexers, to multiplex them into 4 analog inputs.

I think I'm going to order MPC3208 chips since 4051s aren't so stable/precise from my experience.

dc42:
You've indicated that you want 4 pins for the rotary encoders. What sort of encoders are they, and why do you think you need op amps to interface them? If they are standard mechanical rotary encoders used as input devices, then you don't need any extra hardware, and you can also multiplex them using diodes. In that case, you could do the whole thing in 18 pins on a Uno, leaving the Tx and Rx pins free for debugging.

They're HDD motors. I've followed this schematic:

Each of them has 2 pins (instead of 3 like in link) and I've connected 1 pin from each into a interrupt pin to Arduino.

kustom:

dc42:
I'm late coming to this thread, but I would use 7 x 5 multiplexing for the LEDs and 7 x 7 multiplexing for the switches. You can use the same column outputs for both the LED and the switches. See attached schematic (which only shows 4 LEDs and 4 buttons). This needs:

7 resistors (for the LEDs)
1 ULN2803 (or 6 x NPN transistors + base resistors)
46 x 1N4148 diode (or 7 x 8-way common anode diode networks)

Would that allow simultaneous button presses + individual LED control?

Yes, of course.

kustom:

dc42:
For the 31 pots I suggest 4 x 74HC4051 multiplexers, to multiplex them into 4 analog inputs.

I think I'm going to order MPC3208 chips since 4051s aren't so stable/precise from my experience.

I can't see why you would have any trouble at all with using 4051s to multiplex potentiometers into analog inputs. Still, the MCP3208 is a good device.