This time lets play with Arduino and a ps2 keyboard.
For the record here comes the ps2 male connectors :
A quick schema :
The sketch :
#include#define KBD_CLK_PIN 3 #define KBD_DATA_PIN 4 PS2Keyboard keyboard; void setup ( ) { keyboard.begin(KBD_DATA_PIN); Serial.begin(9600); delay(1000); } void loop ( ) { if(keyboard.available()) { // reading the "extra" bits is optional byte extra = keyboard.read_extra(); // must read extra before reading the character byte char c = keyboard.read(); boolean ctrl = extra & 1; // is bit 0 boolean alt = extra & 2; // is bit 1 if (ctrl) Serial.print('^'); if (alt) Serial.print('_'); //if (c==PS2_KC_UP) Serial.print("up\n"); //if (c==PS2_KC_DOWN) Serial.print("down\n"); //if (c==PS2_KC_BKSP) Serial.print("backspace\n"); //if (c==PS2_KC_ESC) { Serial.print("escape and reset\n"); keyboard.reset(); } Serial.print(c); //lets print last input char to our serial monitor } }
(the PS2Keyboard library : PS2Keyboard)
A picture (i used female – male proto wires so that I did not have to cut out my ps2 keyboard wire).