# How can I convert a 2 prong connector to USB?

I'd like to convert this: http://www.parts-express.com/pe/showdetl.cfm?Partnumber=060-640&utm_source=googleps

to a USB? An ideal solution for me because of cost would be to use an existing usb controller from a usb keyboard. I was hoping someone might help bridge the gap in steps. What is necessary to wire the connector to the usb controller? Any help whatsoever would be much appreciated.

This calls for an FTDI FT245R. FTDI has become the standard for interfacing USB in a simple way to microcontrollers and other digital I/O.

The FT245R has 8 parallel I/O, so you can connect the switch with a pull-up resistor to one of those.

edit

Looks good. You connect the switch as follows:

VCC goes to VCCIO, Vout goes to one of the inputs D0..D7. I wouldn't solder directly to the module, but use a socket like this instead:

That's it. The advantage over the RS232 interface is that you have 8 I/O at your disposition.

The yellow jumper on the board selects between 3.3 V and 5 V for the I/O. This is important if you want to connect to a microcontroller or other external logic, but for the switch it doesn't matter.

• Do you happen to know any good guides for implementing this? – stormist Jul 13 '12 at 16:06
• @stormist - this is everything you need. Connect the switch between ground and one of the I/Os (D0 through D7), and connect a 10k pull-up resistor to Vcc. The input will be logic 0 when you press the button, otherwise '1'. What else do you need help on? – stevenvh Jul 13 '12 at 16:13
• aliexpress.com/store/product/… Do you mean this? Please forgive my ignorance in this area but what type of wiring would be best? When you say connect to ground what exactly do I connect the other side of the wire to? – stormist Jul 13 '12 at 21:38
• @stormist - I see you accepted Russell's answer, but I thought I'd still explain the module you asked about. With its 8 I/Os it may come handy for other projects. – stevenvh Jul 14 '12 at 5:48
• Stevenvh do you happen to know where I might purchase one of those sockets? – stormist Jul 25 '12 at 22:02

(1) If you have a working USB keyboard, wiring two wires from the switch across the 2 contacts from a key switch would allow your switch to simulate the switch. This could eg be "A" and it could send an "A" every tie it was pressed. Or something like the "Print Screen" key which would be detectable but would not affect most programs' operation. Or eg "f12" which may or may not be "harmless" in normal use.

(2) You could use a cheap (from \$5) serial to USB adaptor and wire the switch to eg the CTS line. This can be detected by a PC program.

Assumption: "PC" with USB used.

• I once saw a big-round-button USB device on sale at an almost tempting price... I think it was supposed to trigger a backup software package or something. – Chris Stratton Jul 13 '12 at 4:49
• [Print Screen] overwrites the current clipboard content. I think the only completely harmless keys are the user-programmable ones. – stevenvh Jul 13 '12 at 10:57
• BTW, are you feeling all right? This is such a short answer.. :-) – stevenvh Jul 13 '12 at 10:59
• How would the wiring of the switch to serial part of the adaptor be done? – stormist Jul 13 '12 at 16:05
• What kind of wiring would I get to wire the key switch to the button? – stormist Jul 14 '12 at 2:34

In the realm of simple-but-evil, having the button connect a 1.2 K or so resistor between USB D- and USB VBus will probably make the core USB driver think that a device has been plugged in to the bus.

Enumeration will of course fail, but depending on host operating system the event could be detected in software.

Otherwise, patch it across one of the switches in a cheap keyboard as Russell suggested.

EDIT: IMPORTANT The pullup should not go to 5v VBus, but to 3.3v regulated from it. However you can probably get away with a slightly larger resistor and a zener diode to ground to regulate the voltage.