Input Matrix with Sensor instead of Buttons

Thread Starter


Joined Jun 6, 2023
Hi all,

I'm currently working on a project where I will be using a large number of sensors to detect the presence of an object.
The sensors go Low when triggered, else are HIGH 5V when not triggered.
As these sensors are arranged in a 16x32 grid, and to avoid having 512 Inputs, I wanted to set these up as an input matrix with diodes and hence only require 48 pins in total. Therefore, I want to setup an input matrix with sensor inputs rather than button switches.

In my current setup i tried using a P Channel MOSFET, but without any success. My idea was that if the Sensor goes Low, this would allow the 5V High from the Row Line to pass through the MOSFET to the Column Line. If the Sensor is High 5V, the Voltage at the Column Line end would be 0V.
When connecting an Arduino Input pin to COL to read if this is HIGH or LOW, I can see that COL never goes 0V but in fact is between 1.5V and 5V depending on the Sensor Input. The Arduino keeps reading the pin as HIGH no matter what.


Does anybody have an idea what is wrong here?
Should I be using an optocoupler instead?



Joined May 24, 2022
Looks as though it should work and simulates as expected.
Using 5V as my simulated power supply and for the sensor output high and a 4k7 pull down resistor on COL I get about 4.4V on the cathode of the 1N4148 with the sensor output low and uV at this point with a 5v sensor output.
What does the Arduino input look like, do you have a pull-up resistor enabled that would source current into the COL line?