PCF8574 button read

Really noobish question - do I need resistor on each button if I'm using PCF8574 for reading their state?

kustom:
Really noobish question - do I need resistor on each button if I'm using PCF8574 for reading their state?

No, just connect the button between ground and the pin.
You have to set the pins to be high before you can read them back.

Great, thanks. One more quick question: what's the maximum number of PCF8574 chips I can connect to Arduino (Leonardo, if it matters)?

That chip has three external address lines so you can have 8 of them.
There is another chip the PCF8574A that has a different internal address so you can have eight of those as well.
If you want more then you have to resort to switching the I2C bus, in that case you can have as many as you want.

I was thinking about ditching 4021 and 74HC595 chips and replacing them with PCF8574 - in that case I would need 11 of them.

Grumpy_Mike:
If you want more then you have to resort to switching the I2C bus, in that case you can have as many as you want.

Can you link me something I would find useful since I don't really know what do you mean with "switching the I2C bus"?

in that case I would need 11 of them.

So that is fine with a mixture of PCF8574 and PCF8574As

I don't really know what do you mean with "switching the I2C bus"?

This picture shows you how to do it.
Imgur

If you used the MCP23017 then you could put 6 on the bus and have 96 inputs. Each of those chips have 16 I/O pins.
There are others as well with more I/O per chip.

Well why it isn't possible to connect 8 of PCF8574s on 2 pins on Arduino and then 8 more on other 2 pins?

kustom:
Well why it isn't possible to connect 8 of PCF8574s on 2 pins on Arduino and then 8 more on other 2 pins?

Grumpy_Mike:

kustom:
Well why it isn't possible to connect 8 of PCF8574s on 2 pins on Arduino and then 8 more on other 2 pins?

I think you forgot something!

Odd I did write the reply. Try again.
Because only two pins are connected to the hardware inside the arduino's chip that handle the I2C protocol.
In other words there is only one I2C bus on this processor so everything must be hung off it.

Grumpy_Mike:
Odd I did write the reply. Try again.
Because only two pins are connected to the hardware inside the arduino's chip that handle the I2C protocol.
In other words there is only one I2C bus on this processor so everything must be hung off it.

Ah okay. Thanks for the help.