Pages: [1]   Go Down
Author Topic: problem connecting a ps/2 keyboard with arduino  (Read 278 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello

I've been trying to use a ps/2 keyboard with my arduino uno to get keyboard input. I downloaded the latest PS2Keyboard library from
http://www.pjrc.com/teensy/arduino_libraries/PS2Keyboard.zip
and here's the code I'm using
Code:
#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  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) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
     
      // otherwise, just print all normal characters
      Serial.print(c);
    }
  }
}

but it's not working.
is there a problem with the code or is it a problem the wiring I have?
please help.... and thanks for your time

note: I'm not using a ps/2 connector instead i just cut the keyboard's wire and connected the four wires directly to 5v, GND, pin8 and pin3 on the uno.
Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Since your code is one of the example sketches I expect we can exclude it as the source of the issue.  In your Serial Monitor session is there a chance your baud rate (lower right hand corner of the screen) is selected as something other than 9600?

Cheers !
Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
note: I'm not using a ps/2 connector instead i just cut the keyboard's wire and connected the four wires directly to 5v, GND, pin8 and pin3 on the uno.
We're to assume from this that you connected the right wire to the right pin?
Logged

Pages: [1]   Go Up
Jump to: