Arduino "presses any key" on a USB keyboard
UPDATE (11/2013) By now, the Arduino Leonardo and many other ATMega32u4 based clones are widely available. When loaded with the Leonardo bootloader they identify themselves as a USB keyboard/mouse. You can easily access these features using the provided libraries: arduino.cc/en/Reference/MouseKeyboard
UPDATE (2/13/2012): Spark Fun publishes a tutorial for an Arduino keyboard. OK, so they cheat a little by using a variant of the ATmega chip, but it is inexpensive and works with the Arduino software, so I think I'll have to give it a try.
UPDATE: Apparently new Arduinos are being release very soon which already include the ability to mimic a keyboard or mouse out of the box! Check out the official announcement!
UPDATE: Another Arduino/USB keyboard project just appeared I wonder if it can be generalized to any ATMega328.
UPDATE: check this out us.cactii.net/~bb/morsekey/ looks like it could be another method for turning any arduino into a usb keyboard!
Tired of waiting to find out how to program Arduino Uno to pretend that it's a keyboard?
I am.
I needed a way to interrupt a PC during boot to get to the BIOS from a remote location. In this case the BIOS works well enough over a serial port, but you can only get there by pushing a real key on a real keyboard in person. Who wants to go down to the lab every time you need to push a button!?
So I looked into recycling an old keyboard for the job: Instructables, Hacking a USB Keyboard
That's a nice enough explanation, but doesn't really get me to writing a program to press keys, never-mind let me press a key via SSH. Although it did show me how to figure out which two wires I need to connect to "press" DEL.
So I figured, I'd try a FET as switch. I started with an MPF-102 FET, but that didn't work very well. Frankly, I'm wondering what an MPF-102 is actually good at. Nothing I've found so far.
Having failed with a transistor, I tried a proper relay. That worked well but then I wondered: What would happen if I just used the suggested PN2222 transistor without the relay? And that just worked. Yay!
Then I added a MAX-232 chip which doubled as a non-USB method for programming the Arduino (an FTDI cable costs $20!, MAX232 is $1.20 or so, plus capacitors) and the lab has digi console servers which let me talk to RS232 via SSH/telnet. That's how I was talking to the console on the PC anyway.
I "stole" the wiring for the MAX232 from the Freeduino Serial.
And pressing the key is as simple as a digitalwrite HIGH for .1 seconds. I simplified one of the stock serial examples to make it interactive, and I soldered some wires to a DB-9 connector (as per the Freeduino schematic).
And it worked! Although, OSX wasn't very helpful. Every time I plugged int the keyboard to test it, it asked me to help it identify why kind of keyboard it was. And then I ran into a feedback loop when I told it to send DEL whenever it got a single character. Turns out DEL is 3 or 4 characters which each tried to send a DEL, and you get the picture.
I deployed it today, and it works perfectly! Then I see this link on Make's blog: MAKE Video audition: Google Reader pedal But *whew*, its OK. They are also only adding a different mechanical switch to a keyboard's guts, not giving you programatic control over the keyboard.
With some shift registers and a bunch of transistors, I could control the whole keyboard with no special software/drivers. In fact, it would work without the target computer ever realizing that it is being remotely operated!
IMG00083-20101025-1512
PS Yes, my wiring could've been neater/cleaner, but I was trying to get something working relatively quickly. I'm very pleased with the functionality, although the appearance is admittedly sub-par.
Arduino "presses any key" on a USB keyboard
UPDATE (11/2013) By now, the Arduino Leonardo and many other ATMega32u4 based clones are widely available. When loaded with the Leonardo bootloader they identify themselves as a USB keyboard/mouse. You can easily access these features using the provided libraries: arduino.cc/en/Reference/MouseKeyboard
UPDATE (2/13/2012): Spark Fun publishes a tutorial for an Arduino keyboard. OK, so they cheat a little by using a variant of the ATmega chip, but it is inexpensive and works with the Arduino software, so I think I'll have to give it a try.
UPDATE: Apparently new Arduinos are being release very soon which already include the ability to mimic a keyboard or mouse out of the box! Check out the official announcement!
UPDATE: Another Arduino/USB keyboard project just appeared I wonder if it can be generalized to any ATMega328.
UPDATE: check this out us.cactii.net/~bb/morsekey/ looks like it could be another method for turning any arduino into a usb keyboard!
Tired of waiting to find out how to program Arduino Uno to pretend that it's a keyboard?
I am.
I needed a way to interrupt a PC during boot to get to the BIOS from a remote location. In this case the BIOS works well enough over a serial port, but you can only get there by pushing a real key on a real keyboard in person. Who wants to go down to the lab every time you need to push a button!?
So I looked into recycling an old keyboard for the job: Instructables, Hacking a USB Keyboard
That's a nice enough explanation, but doesn't really get me to writing a program to press keys, never-mind let me press a key via SSH. Although it did show me how to figure out which two wires I need to connect to "press" DEL.
So I figured, I'd try a FET as switch. I started with an MPF-102 FET, but that didn't work very well. Frankly, I'm wondering what an MPF-102 is actually good at. Nothing I've found so far.
Having failed with a transistor, I tried a proper relay. That worked well but then I wondered: What would happen if I just used the suggested PN2222 transistor without the relay? And that just worked. Yay!
Then I added a MAX-232 chip which doubled as a non-USB method for programming the Arduino (an FTDI cable costs $20!, MAX232 is $1.20 or so, plus capacitors) and the lab has digi console servers which let me talk to RS232 via SSH/telnet. That's how I was talking to the console on the PC anyway.
I "stole" the wiring for the MAX232 from the Freeduino Serial.
And pressing the key is as simple as a digitalwrite HIGH for .1 seconds. I simplified one of the stock serial examples to make it interactive, and I soldered some wires to a DB-9 connector (as per the Freeduino schematic).
And it worked! Although, OSX wasn't very helpful. Every time I plugged int the keyboard to test it, it asked me to help it identify why kind of keyboard it was. And then I ran into a feedback loop when I told it to send DEL whenever it got a single character. Turns out DEL is 3 or 4 characters which each tried to send a DEL, and you get the picture.
I deployed it today, and it works perfectly! Then I see this link on Make's blog: MAKE Video audition: Google Reader pedal But *whew*, its OK. They are also only adding a different mechanical switch to a keyboard's guts, not giving you programatic control over the keyboard.
With some shift registers and a bunch of transistors, I could control the whole keyboard with no special software/drivers. In fact, it would work without the target computer ever realizing that it is being remotely operated!
IMG00083-20101025-1512
PS Yes, my wiring could've been neater/cleaner, but I was trying to get something working relatively quickly. I'm very pleased with the functionality, although the appearance is admittedly sub-par.