I'm having difficulties getting the PJRC PS2 keyboard library working reliably with the Arduino Leonardo. I'm relatively new to using the Arduino, but this library seems to be the recommended way to read PS2 keystrokes.
When I run the example sketch to echo keystrokes to the serial terminal, I get about 50% of the characters echoed correctly. The other half typically consists of random characters. In addition, I'd say only 30% of the keystrokes are actually detected at all. I tested many keys on the keyboard to see if there was a mechanical fault but this mis-identification and detection lag happened to all of them.
I get very different results using code from this blog which just implements the PS2 protocol in a barebones way. All of the scan codes echoed from this program are consistent (and correct after I manually looked them up) and there is no lag in detection.
So I could implement my own lookup tables with the second example but I'm curious if there is a known fix for the PJRC lib. There are more features in that library that I would like to make use of. Thanks for any help.
DATA
and pin 3 forCLK
in both cases. – Matt Ball Dec 9 '12 at 18:16