Error: Ps2keyboard library Error Compiling

I am new ,and I am trying to compile the ps2keyboard library and skatch to be able to try it on my uno
I use software Arduino 1.0.5
Every time I try to compile the below I got errors and I was able to solve most of them ,until I reached the below error I don’t know what to do next

#include <PS2Keyboard.h>

#define DATA_PIN 4
PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DATA_PIN);

  Serial.begin(9600);
  Serial.println("hi");
  delay(1000);
}

void loop() {
  if(keyboard.available()) {
    byte dat = keyboard.read();
    byte val = dat - '0';

    if(val >= 0 && val <= 9) {
      Serial.print(val, DEC);
    } else if(dat == PS2_KC_ENTER) {
      Serial.println();
    } else if(dat == PS2_KC_ESC) {
      Serial.println("[ESC]");
    } 
  }
}

I got the above code from http://playground.arduino.cc/Main/PS2Keyboard

And my error as below :

[color=orange]In file included from C:\Program Files\Arduino\hardware\arduino\cores\arduino/Stream.h:26,
                 from C:\Program Files\Arduino\hardware\arduino\cores\arduino/HardwareSerial.h:28,
                 from C:\Program Files\Arduino\hardware\arduino\cores\arduino/Arduino.h:193,
                 from sketch_jan03a.ino:4:
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h: In member function 'size_t Print::write(const char*)':
C:\Program Files\Arduino\hardware\arduino\cores\arduino/Print.h:51: error: 'strlen' was not declared in this scope[/color]

For more the details of first three lines of error are the below
The written in stream.h in line 26 is #include "Print.h"
the written in HardwareSeria.h in line 26 is : #include "Stream.h"
the written in Arduino.h:193 is : #include "HardwareSerial.h"

kindly help me :slight_smile:

Whenever you find errors popping up that seem to related to a library, go to that library and look at the *.cpp and *.h files. The PS2 library should be in a subdirectory below where you installed the Arduino IDE. For example, if you installed the IDE at:

C:/ Arduino105

then the libraries should be at:

c:/Arduino105/libraries

You would find the PS2 info at:

c:/Arduino105/libraries/PS2Keyboard

If you look in the PS2Keyoard.h file, you will see that you have defined two the symbolic constants (PS2_ENTER and PS2_ESC) incorrectly. In the PS2Keyborad.cpp file, you will see that the PS2Keyboard class constructor requires two arguments, not just the DATA_PIN. You need to add something like:

#define INTERRUPTPIN 2
// ...some code
  keyboard.begin(DATA_PIN, INTERRUPTPIN);

Finally, practice making intentional errors in a program that you have already successfully compiled (e.g., remove a semicolon, misspell a keyword, etc.) and see what kind of error message the compiler gives you. That way, you'll have a better idea of where to start looking for the error based upon the nature of the compiler's error message.

first i would like to appreciate your reply unfortunately i checked the libraries and the err but i got the same error i cannot pass them why it's so hard

thank you for your help again :D

but i got the same error i cannot pass them why it's so hard

I'm not 100% certain that I understand this statement.

I went to the link that you posted, and followed that to the PJRC site where the library is actually hosted. I downloaded the library (version 2.4), fired up 1.0.5, and copied and pasted your code. I get completely different errors than you do.

The begin() method takes two or three arguments. You are calling it with one.

PS2_KC_ENTER and PS2_KC_ESC are not defined in the library. PS2_ENTER and PS2_ESC are

There are two examples provided. Try them, before writing your own.