Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How can I turn a Keyboard's buttons into switches? (Embedded Sys)

  1. Sep 23, 2011 #1
    I'm working on a project in my job, but being only a student in CE and Comp. Sci. I'm limited in knowledge.

    I'm looking for a way to communicate with an arcade game, with a standard PS/2 Keyboard. Eliminating the standard joystick and buttons and using a keyboard instead. What would be the best and efficient way into tapping into PS/2 data and clock signals and get them to act as a switch? Where " W " key is UP, S is down, etc etc.

    Basically I'm looking for the complete opposite of a Keyboard Encoder, which I imagine would be a Decoder. I've seen some Atmel chips that will do the job but I'm just not sure if theres another more easier way? As of now, what I do is rip the keyboard open and rewire it. This method is time consuming and I know theres something like a Decoder where the ASCII signals can be tapped into with much ease, and I can reprogram them to have them act as switches..

    Any insight?
  2. jcsd
  3. Sep 23, 2011 #2


    User Avatar
    Homework Helper

    PC keyboards generate scan codes, you can start with this wiki article:


    I'm not sure what you'd need to provide an interface to power the keyboard and received the scan codes.
  4. Sep 24, 2011 #3
    Yeah the interface is mainly what I'm looking for in this case. I know each key has their own code, and the keyboards vary with their signals and it all gets interpreted by the computer ( our home PC ). But when It comes to embedded systems I can see that things get more complex.

    If im not mistaking each keyboard would have to be programmed differently in this sense if I were to make each key act as a switch. An IBM keyboard would give it's signals from key A, and a Logitech Keyboard ( both PS/2 ) would give off it's own unique signal for letter A?

    Or if theres anybody here that can confirm to me logically or by experience that an MCU can can read these signals without having to actually #define them and layout the entire matrix? If so, can a simple If() statement be used to ground a specific unique port for different characters?
  5. Sep 24, 2011 #4


    User Avatar
    Homework Helper

    All PC keyboards use the same scancodes, although some have have more keys and more scan codes than other keyboards. The scancodes for w a s d would be the same for any PC keyboard. Link from the wiki article about interfacing with a PC keyboard:

    Last edited: Sep 24, 2011
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook