geekhack

geekhack Projects => Making Stuff Together! => Topic started by: adventurepoop on Sun, 18 May 2014, 00:58:55

Title: Wiring for 5 key keyboard w/ Trinket
Post by: adventurepoop on Sun, 18 May 2014, 00:58:55
I'm making a 5 key keyboard using cherry mx reds, and an Adafruit Trinket. How will the wiring look for this? I was going to wire all the switches to the 5v on the Trinket and then have each switch on its own io. Would this work?
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: OverKill on Sun, 18 May 2014, 21:31:36
Yes that would work. You would have 2 IO's for each switch though if you did that. the other way would be to have one row and 5 columns (one for each switch). Don't forget your diodes.
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: hanya on Mon, 19 May 2014, 01:35:34
Trinket uses PB3 and PB4 (#3, 4) for USB connection by V-USB, if you make USB HID. You have only 3 pins remained, PB0-PB2. If you use resistance voltage-dividing to detect which button is pushed, you can add more buttons. But I'm not sure they can push at the same time with the way.
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: adventurepoop on Mon, 19 May 2014, 09:43:32
Hanya that's what I'm worried about, but I'm a bit of a beginner with electronics :o Could I possibly wire it so that each button gives a different combination of io, as in switches are a through e and ios are 1-3
a ->1
b ->2
c ->3
d ->13
e ->123

Would this prevent all ghosting on switches a and b?
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: OverKill on Mon, 19 May 2014, 16:47:39
Hanya that's what I'm worried about, but I'm a bit of a beginner with electronics :o Could I possibly wire it so that each button gives a different combination of io, as in switches are a through e and ios are 1-3
a ->1
b ->2
c ->3
d ->13
e ->123

Would this prevent all ghosting on switches a and b?

Just to clarify, You want to use A = PB0, B = PB1 and C = PB3. then you want to D to be detected on PB1 and PB2 (at the same time) and E = PB0, PB1, PB2?
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: adventurepoop on Mon, 19 May 2014, 16:50:55
yup!
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: Smasher816 on Mon, 19 May 2014, 23:39:52
Hanya that's what I'm worried about, but I'm a bit of a beginner with electronics :o Could I possibly wire it so that each button gives a different combination of io, as in switches are a through e and ios are 1-3
a ->1
b ->2
c ->3
d ->13
e ->123

Would this prevent all ghosting on switches a and b?

Just to clarify, You want to use A = PB0, B = PB1 and C = PB3. then you want to D to be detected on PB1 and PB2 (at the same time) and E = PB0, PB1, PB2?

yup!

If that is the case then there would be no way to determine if D is pressed of if both A and B are both pressed - the signals will be the exact same.

Maybe just get a teensy (or some other controller with more IO ports)? They are fairly cheap and are used for many DIY type keyboard projects (Ex: the ErgoDox). Another nice thing about the teensy (or other atmega32u4 based boards) is that people have already written various firmware for it.
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: adventurepoop on Mon, 19 May 2014, 23:55:25
The problem is that the teensy is larger than the trinket by a decent amount. I'm just going to deal with the ghosting in this version, and if I do a second one I'll figure out something better, maybe using a pcb. I dunno.
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: Smasher816 on Mon, 19 May 2014, 23:56:48
Good luck :)
Title: Re: Wiring for 5 key keyboard w/ Trinket
Post by: bcg on Thu, 22 May 2014, 21:32:22
Some fairly simple logic would make this a bit more usable...

for example when scanning the matrix, if 1 and 3 are on, check and see if a or c was pressed previously... if not they probably just pressed d.  Otherwise you can deduce that the other 2 keys were pressed individually.  Also, depending on what the keys are meant to do, you could contrive the wiring such that it is unlikely that you would have ghosting conditions.  I'm kind of tired so I'm sure I'm not explaining it very well, but hopefully you get the point.