Let's Make Robots!

Connecting a PS2 Keyboard to an Arduino

This is my first post.

My name's is Eddy and I'm a teacher from Portugal. I'm helping a student with a project - persistence of vision - and i need help on Connecting a PS2 Keyboard to an Arduino. The ideia is to type the letters using a keyboard...

I'm trying to compile this exemple:

/*  PS2Keyboard library example
  PS2Keyboard now requries both pins specified for begin()

  keyboard.begin(data_pin, irq_pin);
  Valid irq pins:
     Arduino:      2, 3
     Arduino Mega: 2, 3, 18, 19, 20, 21
     Teensy 1.0:   0, 1, 2, 3, 4, 6, 7, 16
     Teensy 2.0:   5, 6, 7, 8
     Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
     Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
     Sanguino:     2, 10, 11
  for more information you can read the original wiki in arduino.cc
  at http://www.arduino.cc/playground/Main/PS2Keyboard
  or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
  Like the Original library and example this is under LGPL license.
  Modified by Cuninganreset@gmail.com on 2010-03-22
  Modified by Paul Stoffregen <paul@pjrc.com> June 2010
#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  5;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin);
  Serial.println("Keyboard Test:");

void loop() {
  if (keyboard.available()) {
    // read the next key
    char c = keyboard.read();
    // check for some of the special keys
    if (c == PS2_ENTER) {
    } else if (c == PS2_TAB) {
    } else if (c == PS2_ESC) {
    } else if (c == PS2_PAGEDOWN) {
    } else if (c == PS2_PAGEUP) {
    } else if (c == PS2_LEFTARROW) {
    } else if (c == PS2_RIGHTARROW) {
    } else if (c == PS2_UPARROW) {
    } else if (c == PS2_DOWNARROW) {
    } else if (c == PS2_DELETE) {
    } else {
      // otherwise, just print all normal characters


and i kept gettin' this errors:


C:\Users\User\Documents\arduino-0022\arduino-0022\libraries\PS2Keyboard\PS2KeyboardExt.cpp:25: error: 'byte' does not name a type

C:\Users\User\Documents\arduino-0022\arduino-0022\libraries\PS2Keyboard\PS2KeyboardExt.cpp:34: error: 'PROGMEM' does not name a type

I've followed this "How To"


Thx a lot


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I noticed you only said you were trying to connect to an arduino without stating exactly which one. The relavent info you posted says that pin 5 can only be used for an IRQ on a Teensy 2.0.

Hmmm.... Sorry for may ignorance!

i think that code is commentend and i don't have the arduino connected...


I'm just try to compile...


Must connect the arduino?


Thx for your reply. The library is not installed, is more like "copy-paste"

I don't have the arduino connected, i'm just try to compile the program...and i have the same errors on Windows and Linux...

It does not matter if you have the board connected or not. You can still get a compilation error as a result of not selecting the correct board in the tools menu.

Exactly, if you don't have the library installed it will not compile.
It is a file that contains the functions you are trying to call.

Install the database and try it again, that will probably work if the code is correctly.

You still need the library installed to be able to compile the program.



It looks like you don't have the library installed correctly.
Remove the directory and reinstall it, try again.

Also, make sure you've got the right board selected, that can make a mess of things as well.