# Need a device that can take single input and covert to a keyboard key press on USB

Let me explain what I'm doing currently.

We have made a finger heart rate monitor, each time your heart pulses a transistor is switched on via its base. The collector and emitter of the transistor are then wired to a dismantled USB keyboard. The wires are wired to the P key on the keyboard.

Each time your heart pulses the letter P on the keyboard is pressed.

While this works its large, fragile and ugly.

Anyone know of a pre-made USB device that can simulate a key press from our heart rate monitor?

• There are lots of more involved solutions, but I would not rule out taking a keyboard and removing everything you don't need (which is almost everything). – Wouter van Ooijen Sep 14 '12 at 14:13

What you're looking for is a "keyboard encoder" or "keyboard emulator", such as these.

They also used to use the term "keyboard wedge" for this sort of thing, but nowadays that term seems to be used exclusively in the context of point-of-sale barcode and credit card scanners.

• All answers very valid but I've gone with this as it's exactly what I was after. It requires no software or alterations to our current mechanics. – Brady Sep 14 '12 at 14:50
• ... and MAME cabinets ;-) – Axeman Sep 14 '12 at 14:50
• @Brady - This is verbatim what you asked for so I can understand you accepted this answer. But 83 dollar is a rip-off. Cannibalizing an existing keyboard for the controller PCB, like Wouter suggests, may cost you as little as 12 dollar; the cheapest keyboard you can find will do, since you won't need the mechanics anyway. For the rest the emulator seems to be exactly the same. Way too expensive IMO. – stevenvh Sep 14 '12 at 15:02
• @stevenvh - I totally agree that $83 is a rip off and don't plan on buying what was linked to. But the names of the devices he provided has yielded some good search results of devices that do just what I'm after at a fraction of the cost. – Brady Sep 14 '12 at 15:06 • I was actually going to suggest that (hacking a keyboard) myself, but a) that's what Brady's already doing, so he presumably wants something better, and b) I've seen too many recent-vintage cheap keyboards that don't use contact closures for the keys. Elastomeric contacts (which probably would work) and capacitance-sensing keys (which probably would not) are quite common. And there certainly are cheaper keyboard emulators out there; those just happened to be the first that I came across. – Dave Tweed Sep 14 '12 at 15:21 I gather that detecting a keypress is not the real purpose, but that you want to detect the digital signal from the transistor one way or another. There are lots of modules with FTDI's FT245R USB interface, which allows you to connect up to 8 digital I/Os. For example this one costs only 9 dollar (and you may even find cheaper ones). If you want to stick to the keypress then completely taking apart the keyboard is a solution. Most keyboards have only a small PCB with the controller, and a connector to the actual keyboard matrix. Find out which two pins define the P key, and connect the transistor between those pins. Then you only need that small PCB, and you can throw away the rest. • Note that this will not press a P as Brady seems to require. Whether that is a good choice on his side is another matter. – Wouter van Ooijen Sep 14 '12 at 14:11 • @Wouter - True, but I imagined that the keypress simulation was more of an emergency solution, for lack of another way to enter the signal into the computer. I'll clarify my answer. Thanks for the feedback. – stevenvh Sep 14 '12 at 14:15 • The reason for the p key press is because I need the heart rate monitor to interface to a web game. – Brady Sep 14 '12 at 14:23 • @Brady - already updated my answer! :-) – stevenvh Sep 14 '12 at 14:25 • @stevenh - The FT245R module design is an excellent idea. With FTDIs drivers it is possible to configure the module to appear as a virtual COMM port in a Window's host computer. Bradley could simply strap the D0-D7 pins to the particular byte code he wants (such as 0x50 in the case of a 'P') and then use his transistor output to pulse the WR# pin on the module interface. His PC software would then use the COMM port instead of the keyboard. If he actually does not have any application software and was just displaying the heart beat 'P's in something like Notepad -- – Michael Karas Sep 14 '12 at 14:27 I'd personally attack this with an Arduino. Simple, tons of existing support from the community and cheap. You could extend the functionality quickly and easily if you so chose to. Here's a relevant link to a rough schematic, code, projects similiar, etc: PracticalArduino Use a microcontroller with built-in USB-transceiver, for example the Atmega32U4, in combination with a software emulator or a simple script or even something like Autohotkey. That will provide a quick, very inexpensive (the Atmega32U4 costs <$4) and also flexible solution for what you're trying to do -- and none of the messing with an actual keyboard either.

You can program the Atmega32U4 to act like a standard HID USB device (a la many keyboards, mouses). You can either use the Atmega32U4 itself as part of your heart monitor, or alternatively just send data via it, using it as the USB-UART interface. See, e.g., this tutorial.

• Yes, pretty much any micro with a USB port or even software USB implementation is going to have something that pretends to be a keyboard as one of its examples. – Chris Stratton Sep 15 '12 at 3:56

Use something like this. Emulate a keypress on a digital pin state change with NETMF asks for no more than 10 lines of C# brackets excluded :-)

There are a ton of USB HID little boards around that do what you ask with about zero programming. One that I've used is the U-HID, http://www.u-hid.com/home/uhid_nano.php