--- /dev/null
+/*\r
+ * an arduino sketch to interface with a ps/2 keyboard.\r
+ * Also uses serial protocol to talk back to the host\r
+ * and report what it finds. Used the ps2 library.\r
+ */\r
+\r
+#include <ps2.h>\r
+\r
+/*\r
+ * Pin 5 is the ps2 data pin, pin 6 is the clock pin\r
+ * Feel free to use whatever pins are convenient.\r
+ */\r
+\r
+PS2 kbd(6, 5);\r
+\r
+void kbd_init()\r
+{\r
+ char ack;\r
+\r
+ kbd.write(0xff); // send reset code\r
+ ack = kbd.read(); // byte, kbd does self test\r
+ ack = kbd.read(); // another ack when self test is done\r
+}\r
+\r
+void setup()\r
+{\r
+ Serial.begin(9600);\r
+ kbd_init();\r
+}\r
+\r
+/*\r
+ * get a keycode from the kbd and report it back to the\r
+ * host via the serial line.\r
+ */\r
+void loop()\r
+{\r
+ unsigned char code;\r
+ \r
+ for (;;) { /* ever */ \r
+ /* read a keycode */\r
+ code = kbd.read();\r
+ /* send the data back up */\r
+ Serial.println(code, HEX);\r
+ // delay(20); /* twiddle */\r
+ }\r
+}\r