0
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« on: September 09, 2009, 05:52:17 pm » |
Hey all,
I've built a custom input device, similar to a one-handed keyboard, around the arduino. Now I'm trying to figure out how can I get the PC to recognize the arduino as a keyboard, and communicate keystrokes.
Right now I'm sending data over serial to an application on the PC, when then generates keyboard events. This approach is obviously not optimal, plus it doesn't work when DirectInput apps, etc, are running.
Any ideas?
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Nowhere
Offline
God Member
Karma: 3
Posts: 851
|-\ |\|\
|
 |
« Reply #1 on: September 09, 2009, 05:58:21 pm » |
One idea that comes to mind is to hack an actual keyboard. Some use matrices where it scans all the buttons row by row and senses if any of the columns are connected. Maybe you could have the arduino put voltage to the columns when it senses voltage from the right row?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 20
Arduino rocks
|
 |
« Reply #2 on: September 09, 2009, 06:53:57 pm » |
To the best of my knowledge, because of the hardware, the computer will only recognize the usb connection on the arduino as a serial link, not as a HID. I have hacked a keyboard before using transistors to toggle multiple key presses (such as Ctrl + anykey) which worked remarkably well. Unfortunately I don't have any of that project documented but there is some good information about that technique on this page http://blogs.msdn.com/ntdebugging/archive/2008/10/10/unlocking-some-puzzles-requires-building-a-better-key-board.aspx.
|
|
|
|
|
Logged
|
|
|
|
|
Huntsville, Alabama, USA
Offline
Sr. Member
Karma: 0
Posts: 327
Arduino rocks
|
 |
« Reply #3 on: September 09, 2009, 07:07:59 pm » |
I think it would not be difficult for an Arduino to emulate a PS/2 keyboard output. If I recall correctly, this is a 0 - 5VDC serial interface. You could then cut up a PS/2 keyboard cable (you should be able to find an extension cable) to get a cable with a male PS/2 (actually a DIN-style) plug. That connector would plug into a PS/2 to USB converter available for about $US5. Here's an example: http://www.emtcompany.com/products/adapters/ps2usb-ps2-to-usb-adapter.htm. -Mike
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 0
Posts: 388
|
 |
« Reply #4 on: September 09, 2009, 07:23:26 pm » |
Now I'm trying to figure out how can I get the PC to recognize the arduino as a keyboard, and communicate keystrokes. If you haven't seen it yet, http://www.arduino.cc/playground/ComponentLib/Ps2mouse has a link to a library at the very bottom of the page. Scroll down until you get to "Emulating a PS2 device". The library can be used to make an Arduino act as a PS2 mouse or a PS2 keyboard.
|
|
|
|
« Last Edit: September 09, 2009, 07:25:25 pm by TBAr »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #5 on: September 10, 2009, 12:02:56 am » |
Thanks for the responses.
I have previously used the hacked keyboard approach for other input devices, mainly arcade controllers which have only a few buttons/switches. The problem with that is that representing a standard 101 key keyboard requires a lot of pins (you'd have to control a 10x11 matrix at least). I'm sure there are clever ways to reduce the pin count, but I'm looking for a more direct approach.
Emulating a PS2 device looks interesting. I'll play around with the ps2dev library linked earlier.
Thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 94
Arduino rocks
|
 |
« Reply #6 on: September 10, 2009, 05:27:11 am » |
I haven't seen any example of using an Arduino as a keyboard, but have seen several projects that use the various Atmel chips plugged into the USB port acting as a keyboard etc.
Do a search in Google for "AVR HID" (HID = Human Interface Device, which is the category keyboards belong to). It should return a number of examples, and you might be able to adapt the code from one of these, or turn your design into a standalone device rather than being an arduino.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 3
Arduino rocks
|
 |
« Reply #7 on: November 16, 2009, 04:15:33 am » |
OlJanx, did you get the ps2dev to work? Because I can't figure out what to do with it.. I would appreciate some help.
|
|
|
|
|
Logged
|
|
|
|
|
New Zealand
Offline
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« Reply #8 on: December 20, 2009, 10:30:44 am » |
For the record http://code.rancidbacon.com/ProjectLogArduinoUSB includes code and a shield design for the Arduino acting as an USB keyboard.  --Philip;
|
|
|
|
|
Logged
|
|
|
|
|
|