Help with CueCat

Can anyone help me with a CueCat?

I am using a 68-1965-A CueCat with Mega 2560 Arduino and Female PS/2 connector. I can power on the CueCat, but I can not read any data on the serial port.

Here is my code:
#include <PS2Keyboard.h>

int DATA_PIN = 8;
int ClockPin = 3;
PS2Keyboard keyboard;

void setup() {
keyboard.begin(DATA_PIN, ClockPin);

Serial.begin(9600);
Serial.println(“hi”);
delay(1000);
}

void loop() {
if(keyboard.available()) {
Serial.println(".");
byte dat = keyboard.read();
byte val = dat - ‘0’;

int c = keyboard.read();
Serial.print(c);
Serial.println("->");
}
}

Umm - the cuecat doesn't use a serial port - it uses a PS/2 keyboard port (completely different protocol, perhaps even voltages, etc).

Have you tried plugging it into a PS/2 port (if you have a computer with one) and scanning a barcode, to see what kind of output you get (basically, plug it in, then open up notepad or some other basic text editor, then scan a barcode - the unit acts as a keyboard, which is why it uses a PS/2 connector).

Also, note that the cuecat outputs a "scrambled" version of the barcode; if you research, you can find out how to mod the cuecat to remove this (it was done in an attempt to keep the system proprietary back in the day).

There were also a few cuecats models that were USB - but they aren't as common to find (just an FYI here).

The PS/2 cuecat IS serial, but it is synchronous, it uses a clock line, and the baud rate is not fixed. But I see you are using the PS/2 keyboard library which takes that into account. I don't think the cuecat needs any sort of special initialization. They are notoriously picky about reading bar codes though, so (if you haven't already) verify your cuecat is working properly by plugging it into an old computer that has a PS/2 port, opening notepad as suggested below, and try scanning some codes. If the cuecat works, and your hand motion is correct, it should 'type' the barcode into notepad.

As for your code, I would try this:

  while(keyboard.available()) {
    Serial.println(".");
    byte dat = keyboard.read();
    Serial.print(dat);
    Serial.println("->");
    }

That should cause it to print a . to the serial monitor followed by a character from the cuecat, followed by ->
It will do that for each and every character output by the cuecat, which for a typical UPC will be a 13 characters including a carriage return at the end.

To read the complete barcode, you will want to concatenate the characters read from the cuecat, watching for a carriage return, which terminates the code string. If you need help with that, lemme know.

I got it working. Thanks for the help. I re-tinned the wires on the CueCat and reconnected it to my Mega. Now it seems to work.
Not sure if something wasn't connected right or the CueCat was being finicky, but its working now.