Button Matrix and 5V+ independant signal, is it possible?

Hi, I am new to Arduino and I am wanting to know if the following is possible.

I have a Leonardo that is running a button matrix successfully with rotary encoders and switches.

I now want to add a +5V button to the matrix. I have found a button sketch that replicates the type of circuit I want to build in to the button matrix. However as the matrix uses digital inputs, e.g. 0,1 or 13,A0, is it possible to have a single analogue, in this case +5V, to say A5 as trigger in the matrix?

This is the sketch I have found and is identical to my physical layout that I want to use with the button matrix.

I can reprogram the base sketch to pin A5 and successfully test my circuit but I don't know how I would implement this into the matrix having only a single input?

Any help would be appreciated, once again I have overestimated my ability by trying to learn new things out of my comfort zone :slight_smile:

what is a +5V button?

a button is a button (a momentary switch I suppose?)

Correct its a momentary switch. So taking GND & +5V from the Leonardo board and in this case the switch output is +5v, I want this output to trigger in the button matrix. But from what I have read so far there does not seem to be a simple way to do this.

And to answer the next question, the switch has inbuilt LEDs that function off the +5v side of the switch.

if I get you right, you want to add a button that will provide power the matrix?
is that the ask?

can you share a schema of the current wiring?

The button is not to provide power, as the matrix is running in digital off the board. It is simply a function of the button I wish to add that its output to the Leonardo needs to be a +5V and that's where I am running in to problems when I come to try and add it to the matrix.

I was thinking (dreaming about it last night lol) maybe I could run the digital signal from the Leonardo through a 5V relay like this 5V relay and let the button power the trigger. Just not sure if the signal is strong enough to pass through? I will buy one today and give it a try.

Here's the layout and the sketch without the add in for the +5V input

[[Primary Matrix](Matrix-1 — ImgBB Matrix-2 — ImgBB)]([Rotary Digital Input](Matrix-1 — ImgBB Matrix-2 — ImgBB))

sketch_BUTTONBOX_V1.0.ino (4.0 KB)

You can. But you need to pull down the A5 pin (to gnd) using, say, a 10K ohm resistor.
The input will be "high" when you depress the button.

I had wired 24 button to a single arduino micro using parallel-to-serial shift registers, and I pulled all the pins low with 20K resistors and pull them high (5V) using push switches. This saves power because when you don't press any button, there will be no current flowing from 5V to GND (beside the ones used to power the shift register)

1 Like

I just confirmed that the arduino library do not allow setting up a pin to be type "INPUT_PULLDOWN", despite it allow you to set it as "INPUT_PULLUP"
Connect a external resistor between A5 and GND. 10K and 20K work.
High value also work, but I think anything higher than 100K will allow the pin to float enough to generate noise.

Thanks, yes I was using a 10K resistor as per the generic button design in my first post, I think the problem is, when used in a button matrix, I need the program to see a signal cross two digital paths.

What I mean here is when you look at the diagrams when a button is pressed it sends a digital signal between A1 and 9. When I introduce a powered input to only one side it does not provide the two digital references for the matrix.

I think I will try using a physical interface to deliver the digital signal by means of a relay like this Relay triggered digital input I dont know if this will work or if I will get a lot of noise because of the coil. I will just have to test and see what happens.