I am trying to read from a ps2 barcode scanner (Datalogic gryphon D). The Arduino is powered by the USB. The circuit is shown below

ps2 connection

The pinout of the ps2 is ps2 pinout I have used the fritzing pin assignments when making the diagram.

I am using the code from here

#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  5;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin);
  Serial.println("Keyboard Test:");

void loop() {
  if (keyboard.available()) {

    // read the next key
    char c = keyboard.read();

The scanner scans and indicates that the scan was successful. The Arduino code shows "Keyboard Test:", but none of the scans show anything. What am I doing wrong?

  • Pin 5 isn't an IRQ pin, is it? You want pin 2 or 3 for that...
    – Majenko
    Nov 18, 2015 at 11:45
  • That article doesn't include those pull-up resistors. PS I doubt you need an added power supply. The maximum current of PS2 (275 mA) is below that of USB. So even adding the few mA that the arduino uses you won't reach the 500mA limit of USB.
    – Gerben
    Nov 18, 2015 at 16:16
  • @Majenko I have edited the question. The pins appear to be in the wrong order because I followed fritzing rather than the physical device.
    – CarbonMan
    Nov 18, 2015 at 19:11
  • @Gerben I put in the pull-up resistors because of an article I found (but can't find again). I have removed them now but it still doesn't read. PS I was connecting through a USB repeater cable and I think it was restricting the current. Getting rid of the repeater allows the scanner to correctly start up, but it is not stable. Most scans fail when it is powered through the Arduino.
    – CarbonMan
    Nov 18, 2015 at 19:58


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.