Need more inputs than the mega has

So I need far more digital inputs than even the mega has, is there a way to use some sort of multiplexer or something to get more inputs? I figure there must be, but how?

Get a digital multiplexer IC like the 74150 (16 channel) or the 74151 (8 channel). For an 8 channel multiplexer, you'll need 4 pins (3 for signal selection, one for input). A 16 channel multiplexer will use 5 digital pins, etc.

Ah that sounds right, but is there another name for it or a more common part? My google-fu isn't finding a place that sells those.

How many more inputs do you require then the standard Arduino Mega has? You do know that you can use the Mega's 16 analog inputs as digital inputs?

Lefty

Just search for "multiplexer" or "digital multiplexer"

http://octopart.com/info/Fairchild/MM74HC151N should get you started

What KIND of digitial inputs? For example, if you want buttons, it starts to make sense to look at external "button controllers" of some kind at relatively small numbers of buttons. You can connect an entire 100+ key keyboard to an arduino with three pins...

Agreed... what are you trying to do with 60+ digital buttons?

I have lots and lots of photo cells, and I want to know when one of them is tripped.

The shiftin example looks like what I want to do, can I just keep adding cd4021's like that? That would be excellent if I can use a regular arduino and not have to use mega's in my project.

Yup, you can add a total of like 16 or something.

You can use the "photo-cells" (assuming you mean LDR? light dependant resistor) as a switch, just make sure when they're "tripped", the voltage is high enough to read on the Arduino. (2.5v ish)

If you want more than just an ON or OFF value.. you'll need to use analog-multiplexers, but if you just want to check the "trip", you'll have to do some testing to make sure the sensors have the right resistance to give you the signal you want.

So 16 cd4021's * 8 pins = 128 devices, not bad! Is there a larger version of the cd4021 with more pins?

I have sized the LDR's now so they trip, I'm supplying 5v from the arduino but I figure after awhile I'll need an external power source as well. Any idea how many I can power this way before needing a power supply?

I have lots and lots of photo cells, and I want to know when one of them is tripped.

Well, if you only care that "one of them tripped", look at a wired-OR configuration. You could theoretically do it with a single input.

If you actually care which one tripped, it's not as simple.

Many IO expanders have, in addition to 8 to 28 IO lines, have interrupt outputs to help you figure out when something tripped.

-j

Yes, I do care about which one tripped. I'm making a "laundromat watcher", I have a working prototype now using a Mega. My laundromat only has 32 washers/dryers so it works with the mega, but my mat is very small so if I make this a commercial product I would need many more inputs.