multiplexing via CD74HC4067

I'm working on a midi foot controller with 8 switches, each of which has an associated LED. When I ran out of input pins, I started looking at multiplexing and bought a Analog/Digital MUX Breakout - CD74HC4067. I believe this can act as both input and output at the same time, to read switches and control LEDs?

However, all the projects I can find seem to use it in one direction, generally for reading things. Can anyone point me at a simple tutorial to show how it can act bidirectionally?

Many thanks....

It is 1 to 16 multiplexer. It means you can connect one (Arduino) pin to up to one of the other 16 pins - as if you connected it with a wire. It is good for multiplexing analog input - you cannot read more than one analog input at the same time anyway. It is not so good for driving something if you need to drive more than one LED or similar load at the same time. You can have only one LED light up. You can switch between two LEDs quickly so it will appear the are both lit at the same time but they will have only half brightness. If you want 3 LEDs "at the same time" it will be only 1/3 of brightness... Also it will consume a lot of processor time. So unless you really have to use this chip for some reason it is better to use something else to drive LEDs. 74HC595 shift register maybe?

Shift register, yes. 74HC595, 70mA total current output, one should limit LEDs to 8-9mA to avoid overstressing VCC or Gnd pin.
TPIC6C595 or TPIC6B595 are much better shift register for sinking current thru LEDs, can get full 20mA no problem, can drive one (8 outputs) or many daisy chained devices (I’ve done 45) with just 3 pins.

cd74HC4067, http://www.ti.com/lit/ds/symlink/cd74hc4067.pdf
one of IO0 to IO15 connects bidirectionally to the common IO pin. If the common IO pin been pinMode’d to output, then you can drive an LED connected to one of IO0 to IO15. If it has been pinMode’d to input, then you can read a switch that is pulled HIGH or LOW (at the switch) that is connected to a different one of IO0 to O15. Keep the series resistance of the part in mind or you may get unexpected results.
pinMode can be used on the fly in loop(). If you cycle thru reading/writing quickly and are driving LEDs, turned-on LEDs may seem dimmer vs just driving them with a shift register.
If you wire up a switch & LED like this, you can read the switch and let it control the LED.
LED and switch.jpg

I’m guessing that last idea would require a latching switch? I’m using momentary. Lots of interesting ideas to follow up, many thanks!

Smajdalf:
You can switch between two LEDs quickly so it will appear the are both lit at the same time but they will have only half brightness. So unless you really have to use this chip for some reason it is better to use something else to drive LEDs. 74HC595 shift register maybe?

I take your point. I bought it as an experiment really, hoping it would offer a quick solution, but maybe not. Is it worth looking at charlieplexing? I'm pretty new to this field..

Maybe port expander like PCF8574 with interrupt on pin change is the right IC for your application?

"I'm guessing that last idea would require a latching switch? I'm using momentary."
Momentary is fine. Read it frequently, drive the LED the rest of the time. When you see the switch change then change the level you drive the LED at. Increase the series resistance so that when switch is closed and the Arduino output is driving, there is not too much current flow (so 4067 Rl + series resistor >= 200) and the pin is not damaged.