I am developing a project that must be placed between 20 and 30 buttons to be pressed by the user.
What is the best microcontroller for use in this project, FEZDomino only has 13 digital outputs, is there any way to expand the digital outputs or is it better to choose another microcontroller??
This is the schematic for the arduino “lcd and keypad shield”.
It uses 4 buttons in the way I described. Don’t know how it will work with that much buttons, but you might be able to multiplex it in some way?
And if you don’t get it to work with one analog input, this example shows how 5 buttons can be used with 1 analog input. Since most fez devices have around 6 analog inputs, this would result in 30 buttons.
I have a 25 key keypad on a 5x5 matrix on Panda. This uses 10 pins and can easily go up. I can share the matrix driver if you like.
I tried the analog way but hit some serious problems above 15 keys or so. One could use multiple analog pins but it gets overly complicated in my opinion.
You can also use a shift register or a dedicated keypad chip but I think there are plenty enough IO on the Panda.
The Domino has USB Host so you could use a PC keyboard encoder and have over 100 keys.
resistor ladder designs work, as was pointed out way up the top of this thread. Whether they’re effective or not is questionable; for the scale of # buttons you have you might have an interesting time calculating the best resistor values to use and the appropriate ranges of values they will return on a Fez. (multiple presses at the same time could be troublesome on that many buttons!)
You could do this for your “prototype” and figure out if there’s a more effective solution later if you just wanted to kick on with the project.
I’ve gone down the resistor ladder route before. There’s a reason they stop at about 4x4 (16) buttons. You can maybe go up to 20, but it gets progressively less accurate and you need resistors with better than 1% tolerance… difficult.
Look at this article and the attached spreadsheet to calculate errors:
I’d rather go with a matrix scan. I’ll try and get my Matrix scan code up on the Code site in the next day or two. Work on a physical layout for your keyboard in the meantime.