A lot of output? Is it possible?

From my understanding you can use the arduino analog input and some resistors to read multiple inputs at the same pin. But is it possible somehow to do kinda the same thing for output? I am running out of pins to use. I got alternative plans to make this work otherwise but is it possible still?

Not quite the same - for multiple digital outputs you can use shift registers or IO expander
shields to give more effective pins (at the expense of slower update).

Did you make a schematic, or can you tell the pin usage ?
We might be able to free a few pins.
Which Arduino board are you using ?

Shift registers.
If you need PWM, then something like TLC5940.

Shift registers, you can drive a lot of them daisy chained and send out data really fast using SPI.transfer();
I have 20 daisy chained using 5 of 8 outputs each to drive the 20 columns of this Nike Fuel Band display:

I have 20 daisy chained using 5 of 8 outputs each to drive the 20 columns of this Nike Fuel Band display

Nice.

Caltoa:
Did you make a schematic, or can you tell the pin usage ?
We might be able to free a few pins.
Which Arduino board are you using ?

I am using the Arduino UNO, I do not got a schematic and I am using 6 digital pins for a LCD screen. Speaking of wich can you hookup a LCD screen with the LiquidCrystal libiary via shift registers?

Shpaget:
Shift registers.
If you need PWM, then something like TLC5940.

CrossRoads:
Shift registers, you can drive a lot of them daisy chained and send out data really fast using SPI.transfer();
I have 20 daisy chained using 5 of 8 outputs each to drive the 20 columns of this Nike Fuel Band display:
http://www.crossroadsfencing.com/BobuinoRev17/Prototype_in_action.MOV

Shpaget and CrossRoads that is exactly what I was looking for! Did some research and they seem to be THE solution to this kind of problem. Now from my understanding you can use the same shift register for input as well as output, but not at the same time. Right? (Like unless you swap between input and output) Because I don't want to buy a bunch of them and then they are output only for example.

Normally they're either input or output. Fixed function.

You can get I/O expanders but they're called "I/O expanders", not shift registers. And they cost more.

fungus:
Normally they're either input or output. Fixed function.

But the same module can handle both functions right? I watched a video which said they worked in reverse if you compare input and output, so they can act as both right?

You can use Universal Shift Registers that will do input and output.
http://www.nxp.com/documents/data_sheet/74HC_HCT299.pdf

Less expensive to have dicrete serial to parallel and parallel to serial chips tho.

@CrossRoads: what's the difference between serial-out and parallel-out shift register [based on the application]? is 74HC299 easier to use than MCP23017?

Serial out means the latch signal would have captured the parallel port input data, say the state of 8 switches, buttons, etc. Then shiftIn() or SPI.transfer would be used to read the data.
Parallel out means shiftOut() or SPI.transfer would be used to move data into the part to show up on 8 parallel outputs.

MCP23017 offers 16 bits vs 8 bits, once you figure out the addressing to access everything it is probably easier. 74HC299 you have to set up the control lines to do the various functions.

MCP23017 only sinks 8mA and sources 3mA. 125mA absolute max into the VDD pin

'HC299 not much better, +/-6mA outputs.

74F299 is better, with 20mA sink capability - but only 3mA source drive.

74AC299 was the best, with 24mA sink and source capability. I bought a tube of 20 when Newark was clearing them out.

There is this clever circuit/software that lets you drive an arbitrary number of output pins implemented on shift registers, from a SINGLE IO pin of the microcontroller:

At some point, you might as well use additional microcontrollers as your "io expanders", in which case you can implement whatever sort of interface you want ("Software Serial" (one wire, output only), Dallas one-wire (one wire, bidirectional), I2C (2 wires, bidirectional, addressable), etc.)

All depends on the application. Need 96 high current sink outputs? Couple of '328Ps won’t do that, are current limited. Need 24 high speed 12-bit ADC inputs? 6 328Ps can’t do that, only slower 10-bit input.
SPI to all those is the best way to go, unless you can arrange parallel interfaces instead, which uses a lot of IO pins.

(and at some point, you should think: maybe I just need a bigger chip with more pins of each type, or a better A-D converter.)
(although, finding a microcontroller with "lots of high-current drivers" will be an interesting to impossible challenge!)

If you use SPI connection you'll use min 4 wires right? MISO, MOSI, SCK & SS(for every slave). Is there a chip equivalent to 74AC299 that use I2C connection(uses only 2 wires--SDA & SCL) and can support 16 I/O?

Read the data sheet, there is a version of this chip that is I2C.

Advantage of SPI is speed - I design for speed.

• High-speed I2C™ interface (MCP23017)

  • 100 kHz
  • 400 kHz
  • 1.7 MHz
    • High-speed SPI interface (MCP23S17)
  • 10 MHz (max.)

If you use SPI connection you'll use min 4 wires right? MISO, MOSI, SCK & SS(for every slave).

Yes, but most shift registers can be chained to you don't necessarily need more SS pins when there's more chips.

Is there a chip equivalent to 74AC299 that use I2C connection(uses only 2 wires--SDA & SCL) and can support 16 I/O?

There's lots of them. Google for "I2C port expander"

I'm experimenting with one right now; the PCF8574A, an I2C chip with 8 I/O lines. I got some for free... :slight_smile:

It's easy to use. It has "quasi-bidirectional" pins so you can mix LEDs and input switches on the same chip. There's 3 address selection pins so you can have 8 chips connected to the bus.

The only downside is that it only supports 100kHz clock frequency. If that's enough for you then it seems like a useful chip for reading switches, driving LEDs, etc.

I'm going to use mine to make an I2C joystick so speed isn't a problem. Having only two wires is much more important so I can use a simple plug for it (USB plug?)