0
\$\begingroup\$

I want to read 256 digital input, each of which is driven by a switch. I don't need to read state of all 256 switches more than 5 times a second (or may be even less). Multiple switches can be ON and OFF at any point in time. Obviously that's too much of wiring if I want to do it naively. So I want to do it as simply as possible without using loads of components or wires. My first thought is to have have 16X16 matrix with diodes. But that's too many diodes to add on to breadboard. So essentially I'm looking for some chip that will have 16+16 input pins that I can use it to feed in rows and columns of the matrix. That chip then will have (may be) 8 output pins that I can read somehow 16 times in succession to get all of 256 bits.

Questions I have...

  1. Does this kind of chip exists?
  2. Is this the best, cheapest and least messiest way to do it?
  3. Can it be done without chip with something like Arduno Mega that already have 56 bit input? I do want to reduce component count.
  4. Should I be using may be combination of chips which does only 8 rows and columns?

If you have any pointer to tutorial/guide to implement this, that had be great as well!

\$\endgroup\$
3
  • \$\begingroup\$ You don't need row diodes if you put every row in high impedance input when they are not active. \$\endgroup\$
    – on8tom
    Commented Nov 25, 2015 at 0:02
  • \$\begingroup\$ No, if there is a possibility of more than 1 switch being closed, you need the diodes no matter what. Otherwise you won't be able to tell which switches are flipped in all cases. \$\endgroup\$ Commented Nov 25, 2015 at 0:17
  • \$\begingroup\$ Well, if you don't wire the switches in a matrix, then you don't need diodes, but you will need 256 input pins and 256 resistors. \$\endgroup\$ Commented Nov 25, 2015 at 0:22

1 Answer 1

1
\$\begingroup\$

You've got the right idea with a diode array. I would recommend building a 16x16 matrix with the switches in series with 256 diodes + a pair of 16 bit I2C or SPI port expanders. Or you could use a pair each of 74165 and 74594 shift registers instead of the port expanders. Solder the diodes directly to the switches when you wire up the matrix, don't stick them on a bread board. You'll also need 16 pull-up or pull-down resistors.

Alternatively, you could daisy-chain 32 74165 shift registers and connect each switch to its own pin. You'll also need 256 pull-up or pull-down resistors.

\$\endgroup\$
10
  • \$\begingroup\$ I want to avoid having any diodes whatsoever. Do you have any example schematics for 74165/74594? Can it be done with 4067 chips? Any examples would be great! \$\endgroup\$ Commented Nov 25, 2015 at 0:17
  • \$\begingroup\$ If you want to connect the switches in a matrix, the diodes are unavoidable. You're going to need 256 of something - either diodes or I/O pins and pull-up/pull-down resistors. \$\endgroup\$ Commented Nov 25, 2015 at 0:21
  • \$\begingroup\$ Why can't these diodes be part of some chip instead of me manually placing each of them on a breadboard? \$\endgroup\$ Commented Nov 25, 2015 at 0:56
  • \$\begingroup\$ Why do you insist on placing them on a breadboard? Why can't you just solder the diodes directly to the switches? \$\endgroup\$ Commented Nov 25, 2015 at 1:02
  • 1
    \$\begingroup\$ The point I'm getting at is that how you drive the matrix is irrelevant. If you don't use diodes, then you will have ambiguous conditions. For example, if you close switches (2,3), (2,5), and (4,5), then (4,3) will read as closed even if it is not. It is impossible to read out a matrix unambiguously without placing a diode in series with each switch. \$\endgroup\$ Commented Nov 25, 2015 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.