On-off-On Switch as HID input wiring

Hello, I am building a button box currently with 5 on-off-on momentary switches and 2 rotary encoders, I would like to wire the switches in a matrix, but I am not sure if I need to have a wire for each of the 3 terminals on the switch, or if I just need two for the ON at either side. And also, I am using diodes to prevent ghosting, which way would I wire them?

Wire them like 10 ordinary (SPST) switches.

There are ways to handle the 5 togglers. Wire the first On terminals together and tie to one input. Then do the corresponding wiring to the other On side if the toggler.
Tie the 5 commons to 5 different strobing I/O.
Total 7 I/O insteda of 10.

1 Like

Sorry for the rough sketch but something like this?

Well done!
If I don't have a bad day You can drop those 10 diodes!
Connect the COM pins of the switches to 5 I/O pins acting like strobes.
But!
Solve the 2 decoders first. Sometimes they need 1 interrupt pin each.

Not if multiple switches can be closed at the same time.

In a 5x2 matrix one can have 2 or 5 strobes, whatever looks easier to build and manage.

So by COM pin, you would mean the middle pin on the momentary switches if I am not mistaken? And i would run a wire from each switch to a slot on the board? As for the encoders, I would just run each to a slot on the arduino right?

Yes, exactly!
By activating those 5 lines, one at the time and then checking the two "On lines" will show the state of the switches, one at the time.

That diagram is a bit muddled. For centre-off switches, since only one side can be ON at any one time, you use a single diode in the common.

Same for any multi-way (rotary) switch - someone else was having this concern recently.

What wiring do You refer to? It can't be my word sallad wiring as each common is strobed one at the time. I thought the strobe to be active low or set as input pullup when inactive.
I know about the matrix keyboard multiple key pressed need for diodes.

Sorry for asking so late, but are the diodes in my diagram the right way round?

If You use a high for activating the switch, com pin in the middle, yes.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.