24 input switches with 12 output pins

Below is what I am trying to accomplish. My experience with Arduino is limited to the basic projects that come with the kit.

INPUT: 24 tactile momentary switches
OUTPUT: 12 pins
Depending on which switch is pressed, 2 of the output pins will be closed (0 ohms), otherwise, they are all N/O.
No 2 switches will be pressed at the same time.

QUESTIONS:
Does 1 side of every switch connect to GND, and the other side to an input? Therefore I will need 24 input ports on the board?

Can someone point me in the right direction to create a sketch to do the above? I don't know where to begin.

I already have a chart showing which input (switch) will trigger which 2 output pins.

I have a UNO R2 and a MEGA 2560 I can use.

Look up "keyboard matrix" (example).

1 Like

Project analysis. Without going 'exotic', you need a 4x6 or 5x5 button array and 12 outputs.
So, I'd say 22 pins of IO. Can't be done on an Uno. Unless, you use a shift register or port expander to increase your pin count, you're definitely doing this on the Mega.
So, do it on the Mega.
Your choice - 5x5 or 4x6 button matrix, or the conceptually simpler 24 inputs wired to buttons. (Please, if you do this, wire the buttons to ground and input, and use INPUT_PULLUP for the pin mode). And, of course, 12 outputs.

Of course, an output should NOT be thought of as NC or NO, nor can you treat it as such. They will be logic 1 or 0, in the case of the Uno either 5V or 0V. If you truly need NC/NO functionality, you'll want to drive 12 relays, and that gets into another discussion, because they can't be driven directly from the Uno outputs.
Ask questions about what you don't understand in what I've said, before we go further.

1 Like

Also if you could explain what the end product is going to do/be for that would be helpful as well. Thanks

2 Likes

Not sure where you get the 22 from. I count 24 for input +1 for ground.

I'm sure I can figure out a 4x6 matrix. Thanks for the tip on INPUT_PULLUP.

I do need NC/NO output - are relays the only solution?

Mostly for testing and academic purposes.

My home oven is on the fritz. The control panel has 24 buttons of the simple membrane type.
There is a 12 pin ribbon cable between the panel and the control board (computer).

Some traces on the membrane are delaminating, casing open circuits and multiple buttons to fail. I cannot solder anything to the thin plastic, and after a couple repairs (using nickel paint that works well, but temporarily) I think my next repair is to replace the control panel with new switches and actual wires. A new panel is 70% the cost of a new oven.

The Arduino will be helpful in testing my proof of concept and I was looking for a useful project with it.

From the service manual:

Capture

Why do you need a MCU to do this switching business?

He explained it:

So that's 10 (as either 4x6 or 5x5) for the switches, plus the 12 outputs = 22 total pins

Yes, if you literally want NC and NO isolated contacts.

But would open collector (or open drain) do?

It is not a necessity, but mostly a challenge for myself. I envision the long term solution will be hardwired.

Hello ProjectVR46

I´ve made a small system requirement review.

In general - Arrays and structs are your friends.

Do you have experience with programming in C++?

The task can easily be realised with an object.
A structured array contains all information, such as pin addresses for the I/O devices, as well as the information for the timing.
A single service takes care of this information and initiates the intended action.
The structured array makes the sketch scalable until all I/O pins are used up without having to adapt the code for the service.
It is cool stuff, isn´t it?

Have a nice day and enjoy coding in C++.

1 Like

Any possibility the current membrane keypad isn’t already a key matrix that is being scanned?

@david_2018 From post#7, it seems apparent that it is. However, it's not clear to me just what the OP is proposing doing - if he's wholesale replacing the unit, there's no need to replicate the scan arrangement, just whatever message get's sent. If there's a message sent, which I sort of doubt.
Not enough info, or not enough time(for me, anyway) to dig through what we've seen. A good read of the service manual , "snippeted" from above, might reveal all.

I don't think the OP needs the arduino at all, just a replacement button matrix with the following arrangement:

--6--  --7--  -----8-----  --9---  --10-- --11-- ----12---- //columns
0,     1,     2,           3,      4,     5,      6         //row 2
7,     8,     9,           Back,   ENTER, Timer1, Timer2    //row 3
ATM1,  ATM2,  OvenLight,   Cancel, Bake,  Broil,  Favorites //row 4
Setup, Clean, MoreOptions                                   //row 5

If the buttons are being scanned, then 12 outputs would not work, you would need to actually connect the row/column together at the button location.

With this being in an oven, you need to be very careful of high voltage. Hopefully the membrane button matrix does not have high voltage on it, but if it is behind a set of plastic button caps it could depend on those as insulation (there were some very old tube radios that had a hot chassis, and relied on the plastic knobs and wooden case as the insulation).

1 Like

Not clear to me that the relays were for the button simulation. Again, the OP needs to tell us more before the thread will converge on useful 'help'.

Thanks for all the responses and useful advice.

My main goal is to learn how I would program an Arduino. I understand there is no practical reason to use an Arduino when it can all be hardwired, but I have it sitting around and thought it would be interesting to replicate the keypad with the Arduino. If I can control the oven through the Arduino it would feel like an accomplishment, but I would hardwire the switches for a more permanent solution.

Someone had asked for more background behind my original question, so I mentioned the oven. I think this has led to confusion. Sorry about that.

In case anyone is curious, here are answers to some questions above:
The keypad is completely passive. It's 2 transparent sheets with switches and traces on them. They are all N/O. Pressing a button completes a circuit between 2 pinouts - I confirmed this with a DMM.
Conversely, on the control board side, I can replicate any button press by shorting out the corresponding 2 pins with a jumper wire.

It is a gas oven. There is 120V going through the control board.

Interesting fact I learned... this control board is used in multiple oven models, with different features. For example I can get it to show convection bake, but I don't have a convection oven.
In my model pins 1 & 8 need to be permanently shorted for the board to know what features to activate. For another model it's pins 1 & 9, etc. This is good to know as now I can look for parts from various models, not just my exact model.

PS I'm not worried about blowing up the house as I'm only replicating the keypad, so it's not like I can get the oven to 1000 degrees or have it do something the control board doesn't allow.

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