[sdiy] usb keyboard matrix hack

WeAreAs1 at aol.com WeAreAs1 at aol.com
Wed Aug 11 00:04:11 CEST 2004


In a message dated 8/10/04 2:38:17 PM, synthos at xs4all.nl writes:

<< So I wondered... Just to keep things simple...
Is there a logic gate that behaves like relais, so I can fake the keys?

Something that behaves like this:
I put 5 volts on pin 1, and pin 2 gets connected to pin 3.
or:
I put 5 volts on pin 1, and the voltage on pin 2 is copied to pin 3.

Does it exist? >>

OK, here it is in oversimplified form:  Assuming that your Pin 1 signal is a 
varying analog voltage (coming from the joystick output?  Do I understand this 
correctly?), you need to feed your 5 volt pin 1 signal into a comparator 
(made from a single opamp or from a dedicated comparator IC such as a LM311 or 
LM339).  The output of the comparator can then be used to turn on an analog 
switch IC such as a CD4016 or CD4066.  Those IC's are quad switches, so they 
contain four separate analog switches -- you'll just be using one of them (the other 
three would be available to simulate other switch closures, if needed).  The 
analog switch would be connected across pin 2 and pin 3.  When the comparator 
turns on the analog switch, pin 1 and pin 3 would be connected together by the 
analog switch, simulating the "real" switch which normally makes that 
connection.  I use 4066 analog switches very often to electronically simulate 
physical button presses on existing circuits.  They work very well for that.  Yes, 
you probably need more details, but that's all I have time for right now.  Maybe 
some other list member can fill in the gaps, or offer a better alternative.

One caveat, however:  The switches in the 4066/4016 can only accept signals 
that are smaller in amplitude than the supply voltage that you're running the 
chip from.  Therefore, if you're running it from a 5 volt supply, you can only 
pass signals that are between zero and 5 volts in amplitude.  If the signals 
normally found at pin 2 and pin 3 are larger than 5 volts (or go negative), 
you'd need to power the 4066 from a supply that is equal to or greater than the 
maximum voltage that you expect from pin 2 and 3.  I hope I have explained this 
clearly enough for you.  If not, go ahead and ask for more details and I'll 
try to help.

Michael Bacich



More information about the Synth-diy mailing list