Which shift register to get

Noob question on parts.

I am working on a project, and I want to add more inputs using shiftIn(). The example on the arduino site uses the CD4021B shift register.

My dumb question is: do I need to have the CD4021B or are there other chips that will work in a similar fashion. I am going to be in Frys Electronics in Phoenix tomorrow, and I would like to pick some up, but I am not sure I will be able to find that exact chip. If I find a shift register with 4021 then name, is that basically the same thing?

I already have some 74HC595's for shiftOut(), but I am thinking that they only work for output. Is that correct?

Thanks,
Rob

http://www.ti.com/lit/ds/snos323a/snos323a.pdf
Pretty standard parallel load, serial out shift register.

'595, serial in, parallel out, correct.

Part like '374, octal latch, can also be wired as a shift register.

What will be connected to the inputs of your shift register? You may be able to avoid the need for a shift register by multiplexing. Alternatively, using an Arduino Mega might be the best option, if it saves using a pile of external hardware.

It will only be used for momentary switches (need at least 14). At this point I believe that only one will be pressed at a time, so I think multiplexing could also work. Would the 4051 chip be the right one to use for this?

Either way I go, I want to buy hardware tomorrow.

Would the 4051 chip be the right one to use for this?

No do not use these chips for outputs.
While changing the select lines because you don't do the change simultaneously (and even if you did) there are intermittent states that can give you false spikes on unintended outputs.

If no more than 2 push buttons will be pressed at a time, the you can multiplex up to 16 of them in a 4x4 matrix with no extra hardware, if you can spare 8 pins. See the keypad tutorial and driver for how to do this. If more than 2 may be pressed at a time, you can still multiplex them, but you need a diode in series with each switch. This is still simpler than the shift register solution, since with shift registers you would also need one pullup or pulldown resistor per button.

If you are multiplexing any other devices - even output devices such as 7 segment displays - then you can share the 4 column outputs with those other devices. The main benefit of using shift registers is that you can read all the switches using only 3 pins.

rjshust:
I am going to be in Frys Electronics in Phoenix tomorrow, and I would like to pick some up, but I am not sure I will be able to find that exact chip

I live near the Fry's on Thunderbird. If you've never shopped Fry's for electronic components, get ready for some fun. They are a distributor for NTE Electronics (http://www.nteinc.com/); some of the their parts are "standard numbered", but most have an "NTE number". Your best bet is to find the NTE parts catalog somewhere on the shelf, thumb through it to find the part, then find that part on the shelf/pegs. Fry's doesn't carry all of the parts that NTE supplies, so you may find something perfect in the catalog, but it won't be on the shelf. Fair warning.

What I typically do to find components is shop online - Digikey and Mouser (and a couple other places) if I need "new stock" items. If I can go with surplus, but I need it fairly soon, I'll use Electronic Goldmine (in Scottsdale, web only though); otherwise if I can wait a bit longer (sometimes the difference is minimal) I'll use All Electronics. Just about every weekend I'll go down to Apache Reclamation and Electronics in south Phoenix to check out what they have (if you don't know about this place, you owe it to yourself to check it out). Beyond that, it's Ebay and chinese suppliers.

Good luck finding your parts. :slight_smile:

Thanks for the locations cr0sh. I live down in Casa Grande, so the Frys on baseline is the closest to me (about an hour away). Ended up staying home over the weekend, so I just ordered the parts online.

Thanks for the help,
Rob

Unless you have a special reason to use the CD4000 series ICs, I would strongly suggest the 74HC series with superior performance, cheaper, will be around into the future for longer.

Some shift registers have a separate output latch (this can be a vital requirement in some situations) and some don't. Some do serial to parallel, some parallel to serial and some do both. Some can shift in either direction. Check your requirements...