Porting Arduino Serial (PS2) Keyboard Library

I came across an this post today. It made me rethink the problem here. The barcodes that I am interested in (and probably most other people) are only comprised of numbers. The code in the linked post is much simpler as it only works for numeric barcodes and might be a better approach for bar code scanners. I haven’t gotten it working yet, but it compiles without error. I would like to tweak/re-write the code here and I think I have the tools to do so, but I am missing one piece. I am not able to generate any output from my barcode scanner yet. It indicates with a beep that a bar code has been scanned but I have not been able to pull the resulting data into the serial monitor. I do not think that I have a hardware issue with the scanner, but I will confirm this over the weekend when I have access to an Arduino. Does the linked code seem like a better or worse approach that using a complete PS2Keyboard library? Does anyone see something obvious that I am missing here in terms of actually generating output from the scanner?

I think it should work fine since Adafruit who sells the barcode scanner is also using the same library for their demo.

The important thing is to know if the port is done correctly and you can at least receive data through the spark core. Once that is established, we can safely get the other demo examples working :wink:

1 Like

Haha, makes sense. The page that is linked in my previous post shows a wiring diagram in which the data and clock wires are receiving power. This is contradictory to other pages and how I have had the scanner connected for all tests up to this point. I tested this alternate wiring setup and it caused an issue - the spark core looked normal (breathing cyan) but in spark-cli it’s status was offline after about a minute of being online and the whole time I was unable to flash anything. I want to confirm my wiring setup so we can make sure the problem is in the library.

Focus on the top half of the image below: clock goes to Spark Core pin A4 (14); ground goes to ground; data goes to Spark Core pin A5(15); +5V goes to a 5V step up. Are there any problems here?

Is the 5V step up powering the core as well?

No, just the scanner

Ok! If that’s the case, be sure to connect the ground of the 5V step up to the core ground as well. :slight_smile:

They’re connected - the ground from the core and the ground from the step up both are linked up to the same column on the bread board

Do you think it would be useful to demonstrate the scanner’s viability by taking a look at the raw serial data, before it translated via the library?

1 Like

I’ll see what I can do today. :slight_smile: it’s hard without the physical device but let’s see how far this can go!

I am extremely appreciative of all the help you’ve already given me. If there is any leg work you think I can accomplish on my end please instruct me. If you think it would help, you can remote access my computer to test out the device - I’m on a Mac.

1 Like

What did you change this to:

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

i would recommend using the following pins as they are 5V tolerant… I hope your analog pins did not blew up~

D0, D1, D3, D4, D5, D6 and D7

I have used a number of combinations - most recently D0 and D1

I’m just wondering about the pins wiring… Where did you get the image from? Also, i guess the scanner is powered up?

I should have specified:

 const int DataPin = 1;
 const int IRQpin =  0;

The image was from this site. The library site has another view of the same pin layout.

The scanner is powered up. It has the red light turned on when the button is pressed down and it recognizes barcodes by beeping and the light turning off.

I also changed this section of the test.ino file. The German line was originally the one that was not commented out, I changed it so that the US line was active instead.

const int DataPin = 1;
const int IRQpin =  0;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin, PS2Keymap_US);
  //keyboard.begin(DataPin, IRQpin, PS2Keymap_German);
  //keyboard.begin(DataPin, IRQpin, PS2Keymap_French);
  Serial.begin(9600);
  Serial.println("International Keyboard Test:");
}
1 Like

Awesome… I’m just wondering if the wiring is correct since the site doesn’t seem to be using the same scanner. (or rather i can’t figure out)

Do you have a multimeter? Can you check between the 2 ends and be sure that the Clock and Data are doing to the right pins? :wink:

The library seems pretty simple and looking at it, it might be a Pull_up setting issue (just guessing)

@btheye, can you try this updated code: https://dl.dropboxusercontent.com/u/36134145/PS2Keyboard.zip

I do have a multimeter - do you mean to check the cord that links the scanner to the leads coming from the bread board? I will check all circuits to make make sure everything is correct. I have some pictures below as well. The amplifier and accompanying wires are not related to the barcode scanner, that assembly is for a load cell. Only the step up and the spark core are involved with the barcode scannner.

1 Like

All connections are good

1 Like

@btheye, can you try this updated code: https://dl.dropboxusercontent.com/u/36134145/PS2Keyboard.zip

Just tried it a couple of times - no change

1 Like