0
\$\begingroup\$

Please forgive my lack of knowledge as all of this is VERY new to me... old dogs and new tricks and all ;)

I want to wire a usb cable to a simple momentary button to use as a push-to-talk button. I've done some LIGHT FIT stuff; built button boxes with zero latency boards and such, but I'm not sure how to find this answer. Heck, I'm not really sure how to search the question.

The button is 2 prong of course. I don't want to utilize a board (learning arduino now, but there's no room for a board in th his project) if it can be avoided, but would rather just have the button connected to the cable and plug it in to have Windows recognize it as a button.

Can I simply wire this button to a usb cable? If so, what fills the remaining 2 positions on the USB connector (data pins I believe) if anything? I don't want to blow up my newly built pc ;)

Thanks in advance for entertaining my ignorance.

\$\endgroup\$
  • 3
    \$\begingroup\$ A simple image search for usb+button gives a load of results. Hack one of those to suit your needs. \$\endgroup\$ – Transistor Dec 19 '17 at 23:01
  • 1
    \$\begingroup\$ One of the easiest ways would be to wire the button to the Velleman K8055 USB experimental interface board. \$\endgroup\$ – Brian Drummond Dec 19 '17 at 23:33
  • \$\begingroup\$ It would be easier to wire it inline with the microphone, then you don't have to write a driver. \$\endgroup\$ – Ron Beyer Dec 20 '17 at 2:40
  • \$\begingroup\$ use the guts from a usb keyboard ... get one that has a programmable hotkey .... or a used usb joystick .... make sure it works with your application before disassembling it \$\endgroup\$ – jsotola Dec 20 '17 at 5:29
  • \$\begingroup\$ Every USB keyboard wires buttons to USB, as do the little lecture-slide-control-laser-pointer gadgets (wireless, most of 'em). 'Shift' is an innocuous choice. \$\endgroup\$ – Whit3rd Dec 20 '17 at 10:14
5
\$\begingroup\$

Cheapest and simplest solution I know of is to find an old USB PC keyboard.

Extract the small circuit board from it.

Run xev on your Linux machine to find which two contacts you have to short together on the board to get some character as an output. You can also trace out the patterns on the keyboard membrane to do this.

Then buy any momentary button and connect it to the two contacts you found.

This way I have PageUp/PageDown footswitches for my notes, when I play piano.

This is home made footswitch from an old PC USB keyboard - it sends PageUp PageDown signal and turns pages when playing piano.

\$\endgroup\$
3
\$\begingroup\$

Unfortunately, you cannot wire a button directly to a USB cable. This will not work. You'll need an MCU to monitor your button, and communicate over USB. Using something like an ATmega32u4 that has a USB transceiver built-in would work. Give this sparkfun tutorial a read.

Note that you aren't limited to using the sparkfun board. I chose that tutorial because it is Arduino-compatible. You could use a different MCU that has a USB transceiver.

I would also research the difference between a virtual COM port over USB (which provides a serial link between your MCU and the PC), and USB configured as a HID (Human Interface Device). For your application, I imagine that you would like to emulate a keyboard (HID).

\$\endgroup\$
  • \$\begingroup\$ Yeah... I've used the nano and uno in other button/potentiometer related DIY projects. Problem is that with this one there is nowhere to put a board in the system. I've got a pic of what I'm doing... but can't figure out how to post it here in the comments... I'd live someone to tell me where the board is in the pic! \$\endgroup\$ – Darksider72 Dec 19 '17 at 23:21
  • \$\begingroup\$ Can you post a link to the photo? \$\endgroup\$ – Daniel Dec 19 '17 at 23:22
  • \$\begingroup\$ Keep in mind that MOST of the black you see at the button is a Velcro loop fastener .... cdn3.volusion.com/nzfzp.aykwu/v/vspfiles/photos/… \$\endgroup\$ – Darksider72 Dec 19 '17 at 23:29
  • 1
    \$\begingroup\$ There is definitely enough room for a small PCB, just not a full development board. \$\endgroup\$ – Daniel Dec 20 '17 at 3:40
  • \$\begingroup\$ So you think there is a board in there? It's like 1" long x .5"... that'd be a tiny little board. I think I may be out of my depth here... that's discouraging lol. I'll just have to find an electronics guru like you guys that I can hire to figure this one out for me lol. I'm not near far enough along in my experience with this I don't think. \$\endgroup\$ – Darksider72 Dec 20 '17 at 6:23
2
\$\begingroup\$

No, USB does not support simply connecting a switch across pins. USB uses a complex comminication protocol that requires a chip.

That said, you could accomplish a simple contact detection using an FTDIchip.com FT232 chip in gpio bitbang mode; these are widely available and have decent software support. But there's no way to just detect a simple switch closure without any additional circuitry. I've read the usb.org specs. It's not at all like the old parallel printer ports.

\$\endgroup\$
0
\$\begingroup\$

I want to wire a usb cable to a simple momentary button to use as a push-to-talk button.

USB has a standard that includes PTT, it's called "HID Telephony"

For that you'll probably have to program a USB microcontroller, or pull apart an existing telephony device and us its circuit.

\$\endgroup\$
-2
\$\begingroup\$

There is one simple way to manage one button on a USB port without full-blown device with full USB protocol. All you need is to pull D+ wire to 3.3V via a 1.5k resistor with your button. You can get 3.3V from VBUS (red wire) with some limit of a 3.3 - 3.6 V Zener diode. This will generate a "connect" event on USB port, and the system will try to figure out what is connected. Then it will fail to get any descriptors, and pop-up a failure message.

Then you need to find a way to intercept this Windows message that says something like "device not recognized" (I believe VBA scripts have means to do so). And trigger your application from there.

ADDENDUM: The above was a really wild idea. In cases like the OP, I usually recommend the multi-functional MCP2221 chip (UART/I2C bridge), which also has few GPIOs, and even ADC/DAC, all with libraries on host side to manage the pins. The entire USB device can fit into 10 x 10 mm area, and can be placed entirely into USB connector overmold. It is not blazing fast and libraries might be not in Visual Studio 2017 format, but anyway.

\$\endgroup\$
  • 1
    \$\begingroup\$ interesting idea, but it would be too laggy for a push-to-talk application \$\endgroup\$ – jsotola Dec 20 '17 at 5:43
  • \$\begingroup\$ @jsotola, upon sensing the low-to-high transition on D+, the host controller generates an interrupt almost immediately. Only then it allows 100-200 ms of de-bouncing delay before initiating USB_RESET and attempting to enumerate the port, three-four times. Yes, the final message is laggy, but if you can intercept/hack the ehci.sys interrupt handler, then it will be pretty fast. You likely can hack Linux/Android kernel for that, if you can... \$\endgroup\$ – Ale..chenski Dec 20 '17 at 7:00
  • \$\begingroup\$ This sounds like a lot of extra work for something that wouldn't be portable between machines... \$\endgroup\$ – Daniel Dec 23 '17 at 18:19
  • 1
    \$\begingroup\$ @DanielGiesbrecht, extra work compared with what? With making a full-blown hardware? And own driver? Connect event is the same across ALL USB systems. If you manage to intercept this event at some "filter driver" level, it will be very-very portable. \$\endgroup\$ – Ale..chenski Dec 23 '17 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.