Making a keyboard with an arduino AND putting the arduino under the pcb

First let me apologize for not knowing much.
See this question on electronics stackexchange for more info.

The picture is the key layout. In the picture, the yellow keys are modifiers. The green keys are letters. Red keys are regular keys which change function depending on which layer key is pressed. The color printed on the key corresponds to function (the white is what will happen if no layer keys are pressed).

Would I need to use two separate matrices (one for the Layer and Mod keys, one for the rest?) Also, I've been using ergodox (http://ergodox.org/Default.aspx as a guide (though I cant open their pcb files). They use a Teensy, which would obviously be smaller than the arduino duo I plan to use. To save space, I was thinking of putting the arduino below the pcb, and separating them with something(to protect the duo). Is this possible? Lastly, how could I design my pcb in Fritzing if they don't have the cherry mx brown switches? Thanks for your helP!

mapMade.png

If you're going to support simultaneous key presses then you can't use a simple matrix. You could use a separate matrix for each set of characters which can't be pressed together, but that would still go wrong if somebody ever did press multiple keys in the same matrix. You don't have a huge number of keys there - have you considered using shift registers to provide a separate input per key?

Nope. The person at Electronics Stackechange said a matrix would work. Will have to research shift registers. Thanks! What about putting the arduino under the pcb? What about my fritzing question?

PeterH:
If you're going to support simultaneous key presses then you can't use a simple matrix. You could use a separate matrix for each set of characters which can't be pressed together, but that would still go wrong if somebody ever did press multiple keys in the same matrix. You don't have a huge number of keys there - have you considered using shift registers to provide a separate input per key?

So I would do I seperate shift register for each key? Which type should I use (SISO, SIPO,, OR PISO)?

fozbstudios:
The person at Electronics Stackechange said a matrix would work.

Did you explain that you wanted to support having multiple keys pressed simultaneously? I don't see how that would work with a conventional matrix.

Google will show you how to use shift registers to provide extra inputs or outputs with an Arduino.

Yes I did. Also, it seems to me that I wouldn't need a pcb. Is this correct?

Would multiplexers be an option?

fozbstudios:
Yes I did.

In that case I don't understand their advice.

fozbstudios:
Also, it seems to me that I wouldn't need a pcb. Is this correct?

What external circuit you use will depend on which solution you adopt. If you believe that a switch matrix will do what you want then you could implement that by wiring the matrix directly to the Arduino I/O pins and I don't see what you'd need a PCB for. If you use any external electronic components such as shift registers or multiplexers then you would need a circuit between that, the switches and the Arduino - a PCB would be one way to make that circuit.

I'm not sure whether you've already committed to using a Duo, but if not then there are some Arduino clones available which include lots of I/O pins - see Cross Roads Electronics for some ideas.

Already commited to duo. I won't have enough pins for my 23 keys (4 short) so I need some sort of input pin multiplying solution. Do you recommend shift registers multiplexers or something else? My biggest headache right now seems to be cramming all of this stuff into such a small space. How tightly can all this be backed? Do you have any suggestions?

If you can use a matrix that would be the simplest approach, but you need to deal with the issue of simultaneous key presses. Can you divide your keys into groups such that there will never be a need to press multiple keys within the same group simultaneously? If so, how many groups and how many keys in each group?

Actually I don't think that would work. I would need two matrices, The fkey button and all modifiers would need the be individually wired, plus I need the mouse, scroll-wheel, and mouse buttons. Would I be able to power the arduino from the main port if I connect to a computer via usb? just use the By the way, I'm actually using the Uno

Yes you can power an Uno from USB.

Thing about the Uno though,is the USB connection is really just a USB-to-serial connection. You would need to write driver software for the PC to convert the Uno's serial data into key press events. If you want to use an Uno but don't want to write a PC driver, I would instead just use the PS/2 port and emulate a PS/2 keyboard with the Uno (see: http://forum.arduino.cc/index.php/topic,19224.0.html).

If you're willing to switch to an Arduino Leonardo, it can act as a USB HID (Human Interface Device) and may be the easiest way to provide keyboard input to a PC.

I will stick with the uno. If I do that, my only options are ps/2 or drivers. Is there a shield I could use to get usable usb data, preferably while still powering the arduino?

fozbstudios:
Actually I don't think that would work. I would need two matrices, The fkey button and all modifiers would need the be individually wired, plus I need the mouse, scroll-wheel, and mouse buttons. Would I be able to power the arduino from the main port if I connect to a computer via usb? just use the By the way, I'm actually using the Uno

This is why I asked you to divide your keys into groups such that multiple key presses did not need to be supported within a group. Is it possible to do that?

What's this about mouse buttons and wheels? You've been talking about keys and I assume this relates to the keypad. Are you also trying to make this device plug in to a computer by USB and pretend to be a PC keyboard and/or mouse? In general PC keyboards support concurrent key presses (you get key down / key up events independently for each key) and if that's what you're trying to emulate then I don't think the matrix approach would be viable. In that case the most obvious approach would be to use a digital input per key, which suggests using input shift registers. A slightly less obvious approach would be to use a resistor ladder to read multiple keys from a single analog input - whether this would be viable would depend how many keys you need to support. And I still have no idea how this relates to a mouse.

Full keyboard and mouse(the kind you used to see between keys on laptops). Sorry if I was misleading See the image I provided earlier for specifics. If the mouse isn't possible, that's fine, though it would be nice. This will be mainly a keyboard.

tylernt:
Thing about the Uno though,is the USB connection is really just a USB-to-serial connection. You would need to write driver software for the PC to convert the Uno's serial data into key press events. If you want to use an Uno but don't want to write a PC driver, I would instead just use the PS/2 port and emulate a PS/2 keyboard with the Uno (see: http://forum.arduino.cc/index.php/topic,19224.0.html).

Could I just flash a hid firmware? See http://mitchtech.net/arduino-usb-hid-keyboard/

Interesting, I didn't realize the Uno had the 'U' chip. Well if yours has the 'U' then it sounds like it will be possible.

So I can flash? Also, if any of you know of any general guides for how to pack electronics into small spaces, they would be of much use