alto777:
In a simple matrix scanned keypad arrangement, you will have a problem if more than one button is pressed at the same time.
This will happen if you have humans playing whack-a-mole.
You’ll need a diode isolated keypad matrix. Google is your friend.
If you are going to learn about and employ a hardware i/o expander, some might argue it would be easier to just expand enough to have each button on its own pin.
Easier perhaps would be to use an Arduino with enough “real” i/o pins.
Another approach would be to hack an old PC keyboard of the kind that has NKRO, “n key rollover”. Again, talk to google.
The PC keyboard might speed development as you could get it working without the hacking part. Or do the hacking in parallel, but you’d always have the ability to put a real unhacked keyblade in there instead for testing.
HTH
a7
I’m very torn on giving each button it’s own pin. More expensive, yes, but much more straightforward to code. I’m interested in the hardware i/o expander and if it would allow me to make sure games like whack a mole were possible.
I do a lot of googling. I found the ‘lights out’ game and that included a port expander that apparently no one else has ever gotten to work. I can’t say that it’s not intimidating but also it appeals to my cheap side so I can use the uno.
Realistically, it’s going to be mostly kids playing with this....and they are less than predictable creatures.
Since you are using arcade switches, adding the diodes to you matrix would be easy.
As for the less straightforward coding, the first step would be to bury any complexity with a bit of software which would let you think of the switches as individuals at a higher level.
You’d probably be writing something like that no matter what button hardware you choose.
A side benefit of doing this would be the ability to swap in and out any of several many ways of providing 25 buttons to the higher level functions.
alto777:
Since you are using arcade switches, adding the diodes to you matrix would be easy.
As for the less straightforward coding, the first step would be to bury any complexity with a bit of software which would let you think of the switches as individuals at a higher level.
You’d probably be writing something like that no matter what button hardware you choose.
A side benefit of doing this would be the ability to swap in and out any of several many ways of providing 25 buttons to the higher level functions.
a7
I thought as much. I am just worried about the whole thing going kablooie if two buttons are pressed at once now.
So my thoughts are.
Use an uno.
Use an i/o expander
create 3 matrix
12 buttons for side "A"
12 buttons for side "B"
Center button
Would this solve the "two buttons pushed at once"? While buttons from side A and side B might be simultaneous, side B would never have two buttons depressed at the same time.
So I guess using a keyboard matrix.... (not actual PIN numbers....)
Pin 1 Matrix A buttons 1-9
Pin 2 Matrix A LED 1-9
Pin 3 Matrix A buttons 10-12
Pin 4 Matrix A LED 10-12
Pin 5 Matrix B buttons 1-9
Pin 6 Matrix B LED 1-9
Pin 7 Matrix B buttons 10-23
Pin 8 Matrix B LED 10-23
Pin 9 C button
Pin 10 C led
If you are going to use an i/o expansion technique, why not go ahead and expand enough so you can have individual buttons!?
Most i/o expansion approaches can support multiple units. The
MCP23S17
I found will let you have 8 devices w/ 16 i/o each!
At a glance, the two matrix idea is plausible, but you are dealing with humans, children no less, and to make hardware depending on only one button on a side being depressed at the same time is asksing for trouble.
Also, the code to scan 3x4 keyboards using i/o expansion will be the most complicated solution. My hair hurts just thinking about it, my comments about burying complexity notwithstanding.
One matrix w/ isolating diodes would fit on an UNO. I'm not sure if the various keypad libraries can account for and exploit such an arrangement.
alto777:
If you are going to use an i/o expansion technique, why not go ahead and expand enough so you can have individual buttons!?
Most i/o expansion approaches can support multiple units. The
MCP23S17
I found will let you have 8 devices w/ 16 i/o each!
At a glance, the two matrix idea is plausible, but you are dealing with humans, children no less, and to make hardware depending on only one button on a side being depressed at the same time is asksing for trouble.
Also, the code to scan 3x4 keyboards using i/o expansion will be the most complicated solution. My hair hurts just thinking about it, my comments about burying complexity notwithstanding.
One matrix w/ isolating diodes would fit on an UNO. I'm not sure if the various keypad libraries can account for and exploit such an arrangement.
a7
I think I like that tack best. I don't mind using the
MCP23S17
You're right about children and then adding on a complexity of trying to create different matrix makes my head hurt and I barley know what I'm doing. I just figured it was the only way.
So-
I'm not quite sure how many pins I would need then. It would give me 16 extra but the UNO has 14? I feel like I would have to put some on a matrix.
Or should I just get 2 MCP so I would have 50 pins and just do them individually?
There is also the time <-> money thing to consider.
Being way closer to the end of my life than to the beginning, time is a bigger factor for me. I would probably just use a mega which would give you way enough pins.
The mega is larger and more expensive. There are mega clones; I've had extremely good luck with cheaper versions of all kindsa Arduino-compatible boards. But I mention luck as I am afraid luck does enter into it…
So I guess if I had the UNO I would go with as many MCP23S17s as needed. There are other expansion techniques and chips, I have only used the I2C version of the MCP23S17.
alto777:
In a simple matrix scanned keypad arrangement, you will have a problem if more than one button is pressed at the same time.
Things are not that hard. In a matrix arranged keyboard 2 buttons can be detected simultaneouslly pressed.
If a third button is pressed it works if that button has no column, no row in commen with the other 2 buttons being pressed. Regarding this last term even a forth button can be safely pressed and detected.
alto777:
There is also the time <-> money thing to consider.
Being way closer to the end of my life than to the beginning, time is a bigger factor for me. I would probably just use a mega which would give you way enough pins.
The mega is larger and more expensive. There are mega clones; I've had extremely good luck with cheaper versions of all kindsa Arduino-compatible boards. But I mention luck as I am afraid luck does enter into it…
So I guess if I had the UNO I would go with as many MCP23S17s as needed. There are other expansion techniques and chips, I have only used the I2C version of the MCP23S17.
a7
My unos are clones. My husband does home automation (not button tho) with Arduino and while we have some official nanos, unos and megas that tends to be for the "semi-perminant house fixture" sort of projects. I don't actually mind getting a mega clone because not only of the time/money but a also because while I enjoy the challenge of programming I am dyslexic and that can make for a hell of a time when debugging complicated things. The matrices are incredibly intimidating for me to wrap my head around.
I would call my previous projects slightly dyslexic friendly because they were read/if/do using sensors. I've never worked with actual buttons (I suppose a bump sensor is a type of button).
Since there are 25 buttons after I would create the matrix and name them I suppose it would be no difference than labeling them
D0-A
D1-B
...
D23- W
D24-X
D25- Y
Or as a part of a matrix where I'd just name them and call them as that.
With the MPC there's also a fork ton of soldering to consider, which, with small kids I can only do after bedtime or 3 Tuesdays from never. The mega would be much more plug and play.
Grab one of these for $11. 70 IO pins, plenty for 25 discrete buttons, layed out however you wish.
And 25 LEDs, layed out to match I guess.
Still have 20 pins for other stuff.
I bought a couple to play with for embedding into another card.
Railroader:
Things are not that hard. In a matrix arranged keyboard 2 buttons can be detected simultaneouslly pressed.
If a third button is pressed it works if that button has no column, no row in commen with the other 2 buttons being pressed. Regarding this last term even a forth button can be safely pressed and detected.
So this is interesting. You are defiantly "team matrix". The keyboard matrix I googled explained it well and was 3x3. 25 buttons divided by 9 would mean I would need 3? control pins? Would that be stable enough?
CrossRoads:
So 10 buttons for 5x5 button matrix,
1 pin string WS2812B LEDs,
Leaves 9 pins for other stuff,
2 for serial downloads, debugging,
7 free in reality.
RFID uses 4 for SPI?
1 for buzzer.
Still have 2 free.
Use them for I2C to something else in the future?
There are 25 buttons. Five columns and 5 rows with a button in each.
I guess less if I matrix them I need less than 10 pins?
yes. I can "assign" an LED to a button so that would work.
RFID needs 4 pins.
1 pin for buzzer but can do analog with that.
I have a few genuine UNOs and lots of cheap clones, and everyone at least accept a downloaded test code and run.Some are running in various projects and work perfectly.
Megas are likely the same good.
Thanks. That does seem like the right idea to go and will save on the complexity of the code and physical design.
CrossRoads:
Grab one of these for $11. 70 IO pins, plenty for 25 discrete buttons, layed out however you wish.
And 25 LEDs, layed out to match I guess.
Still have 20 pins for other stuff.
Your link to Dupont doesn't work by some reason. Spending a few bucks can be well used money. Being narrow minded of costs lots of work.
A matrix for 25 buttons need exactly 5 + 5 I/O. Not "less then". Depending on the application, demands for diodes arrises in the case that 3 or more buttons might be activated at the same time.
Using a matrix design cuts down the amount of cables into the controller. I bought a 4 by 4 ready made keyboard just for fun. Using single buttons calls for some cable work, connecting the buttons to each other, in order to end up having those 5 rows by 5 column cables then being connected to the controller,
Railroader:
Your link to Dupont doesn't work by some reason. Spending a few bucks can be well used money. Being narrow minded of costs lots of work.
A matrix for 25 buttons need exactly 5 + 5 I/O. Not "less then". Depending on the application, demands for diodes arrises in the case that 3 or more buttons might be activated at the same time.
Using a matrix design cuts down the amount of cables into the controller. I bought a 4 by 4 ready made keyboard just for fun. Using single buttons calls for some cable work, connecting the buttons to each other, in order to end up having those 5 rows by 5 column cables then being connected to the controller,
Link to board
So I guess do the knock off mega AND a matrix? Probably better to not deal with so many wires.
That's a usual Mega. I've got one but used it yet. I guessed You wanted to show some kind of keyboard, button matrix mounted.
For a matrix set of button even an UNO would do fine. Using a Mega is a bit overkill but it will work. Plenty of spare I/O for future expansion.
You will need to connect a lot of wires to the controller but the priciple is simple. Just keep on working,
I don't know the Mega much but I assume You can define the I/O pins as "INPUT_PULLUP". Then connect one line to one pin of every button and to GND. The other pole of the button goes directly to the Mega.
Railroader:
That's a usual Mega. I've got one but used it yet. I guessed You wanted to show some kind of keyboard, button matrix mounted.
For a matrix set of button even an UNO would do fine. Using a Mega is a bit overkill but it will work. Plenty of spare I/O for future expansion.
You will need to connect a lot of wires to the controller but the priciple is simple. Just keep on working,
I don't know the Mega much but I assume You can define the I/O pins as "INPUT_PULLUP". Then connect one line to one pin of every button and to GND. The other pole of the button goes directly to the Mega.
I figured it was a "regular" mega but I've only ever worked with the Uno so I have a bit of hesitancy to jump in
Since UNO only has 14 digital, I'm not sure how I could get a 5x5 matrix, (10 pins needed) addressable LED (1 pin), RFID (4 pins), Buzzer (that'd be analog actually) and then if I wanted to add additional addressable LED then I'd need 2 more pins.
So I see 10+4+2 minimum which is 2 more than the Uno would offer, correct? Unless I ran the addressable LED from the analog which I'm not sure I can do? If I can then my problems are solved and I'm good with Uno.
The 5 by 5 button matrix can use 5 digital outputs and 5 analog inouts for example. For LEDs You need digital outputs, and the buzzer. It would work, just do some puzzling regarding the pins. Check the needs for the RF reader first.