Controlling multiple things using one pin.

(deleted)

With a '595, you would typically shift a byte to it representing the state of the 8 pins, and then pulse latch to apply the values (some tutorials tie latch to the clock pin; you wouldn't want to do that). You can daisy chain multiple, and then send N bytes (where N is the number of '595's) if you need more outputs - as long as you don't pulse the latch until you've sent all the data out to it, the output pins don't "cycle".

For a more sophisticated solution (for example, if you need digital inputs) you want what's called a "port expander" - these are available as I2C or SPI devices, with 4, 8, or 16 I/O pins, which you can set as inputs or outputs, and read or write as you please. Many of them also have pullups (like INPUT_PULLUP) that can be enabled if desired. With SPI devices, you can have multiple of them on the SPI pins, with just a different pin for each one's CS line. With I2C ones, you can have multiple of them on the I2C bus (2 pins, A4/A5 on the Uno) if the chip has an "address" pin or pins that let you control what I2C address it has.

The MCP23017 is an example of a 16 pin I2C port expander, with 3 address pins (so up to 8 on one I2C bus). Even available in DIP if you've got SMD-phobia (though I'd prefer to solder an SOIC SMD package over a DIP one any day - once you learn drag soldering, you'll wonder wtf is wrong with all these people who don't like SMD parts - and the MCP13017 also comes in an SMD version).

There are also some really crazy ones like the PCA9685, which is output-only, but supports PWM (12 bits - instead of 8 like analogWrite), at a configurable frequency so you can even drive servos with it.

Edit: Yeah, I meant 23017

PCA9685 :slight_smile:

https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA9685PW118/568-11925-1-ND/5221902

I think DrAzzy was thinking MCP23017

https://www.digikey.com/product-detail/en/microchip-technology/MCP23017-E-SP/MCP23017-E-SP-ND/894272

Well, there's the ATmega328p and similar microcontrollers. They could receive commands over a serial/uart pin and do ... anything with the rest of their pins. You can even use a cheap Arduino pro-mini clone as the "chip" - it will simplify some of the details...

(I have a lot of trouble understanding why people spend $10 for a MAX7219, when you can get an ATmega328p (even from US distributors) for a fraction of that price. Yeah, the Max has some convenient features like built-in current limiting. But not $7 worth!)

@Tehnerder
Maybe you could elaborate a little on your use case?
You happen to have only one spare PIN on your µC or just one wire between two locations?