Pages: [1]   Go Down
Author Topic: Arduino as Keyboard  (Read 1813 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
God Member
*****
Karma: 3
Posts: 852
|-\ |\|\
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Soundcloud page: http://soundcloud.com/beefinator-2
Youtube channel: http://www.youtube.com/user/beefinator14
Old soundcloud page (ran out o

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Sr. Member
****
Karma: 2
Posts: 327
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

For the record http://code.rancidbacon.com/ProjectLogArduinoUSB includes code and a shield design for the Arduino acting as an USB keyboard. smiley

--Philip;
Logged

Pages: [1]   Go Up
Jump to: