I am working on a project that the position of people walking along a path needs to be known. I'm a hobbyist so I don't know what options I may have.

I want to use IR sender and receivers to detect the position of people. I need to use around 20-25 sensors (one every 50cm). The easiest solution that may come to mind is to connect each IR receiver to one pin of my Arduino, but it requires too many pins and also huge amount of wires. To use less pins and wire I thought I could use an arrangement like analog keyboard, similar to the following image, keys representing IR sensors.

enter image description here

But this way only one input can be detected. Is there any way to detect multiple inputs using only a few wires?

  • \$\begingroup\$ Three wires, called Load (out), Clock (out) and Data (in). (Plus power and ground). And a bunch of Parallel In Serial Out shift registers, in a daisy chain. I expect you can figure out where to go from there... \$\endgroup\$
    – user16324
    Jan 1, 2016 at 18:56

2 Answers 2


Use resistors spaced apart by a factor of at-least 2

eg: 1K, 2.2k, 4.7K, 10K, 22K, 47K, 100K, then combinations will non-ambiguous.

7 resistors per 10-bit ADC input is about all that seems likely to work well. use 680 ohms for the fixed resistor.

  • \$\begingroup\$ That's a cool way to do it with only 2 wires! \$\endgroup\$ Jan 1, 2016 at 22:18
  • 1
    \$\begingroup\$ only 2 wires per for only 7 switches, each additional set of 7 switches needs another wire, \$\endgroup\$ Jan 1, 2016 at 22:56
  • \$\begingroup\$ Thanks a very cool idea, If I use 1K, 2K, 4K, 8K, 16K, 32K, 64K resistances I can read the input and with minor coding detect active sensors. \$\endgroup\$
    – ahmadx87
    Jan 7, 2016 at 5:52
  • \$\begingroup\$ you'd need 0.05% (precision) resistors if you go with exact multiples of two, using the E12 sizes i suggested allows use of much cheaper 2% parts. \$\endgroup\$ Jan 8, 2016 at 4:09

You can arrange your sensors in a matrix orientation, then depending on your scan rate, you can very quickly check each sensor to see if it's active. You could handle 25 sensors with 10 digital pins in this way.

Energize each row in turn, and while energized, check the values of Columns 1-5.


simulate this circuit – Schematic created using CircuitLab


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.