Go Down

Topic: PS/2 Barcode Scanner Output (Read 233 times) previous topic - next topic

murf_3

Hi,
I have the PS/2 version of the Adafruit MCR12 barcode scanner
https://www.adafruit.com/product/1202
Im connecting it to an Arduino Mega with this adapter cable
https://www.adafruit.com/products/804
Im using PJRC's PS2Keyboard library and the simple test example code to try get the scanner working
https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html


My problem is when using the scanner with the Arduino it powers on and gives the indication beep when a barcode is scanned but the output in the serial monitor is just random characters. It is not a Baud rate issue as im using all the scanners defaulted settings
https://cdnshop.adafruit.com/datasheets/MCR12_configuration.pdf
I have good connections from the adapter cable to the arduino as i have soldered solid core wires on and have wired it as:
  • Black to GND
  • Green to 5v
  • Yellow (clock) to D3 (interrupt pin)
  • Brown (data) to D2


The scanner works when plugged directly into a PC.
The Code and adapter cable work with just using a PS/2 keyboard.
The scanner has a male and female connection so if the keyboard is connected to arduino along with the scanner the keyboard no longer works correctly and gives random output characters.
The device was also tried with other interrupt pins and with an Uno with the same results.

I really have no idea what to try from here and any help is needed and would be appreciated, thanks.


Code: [Select]


 
 #include <PS2Keyboard.h>

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

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

void loop() {
  if (keyboard.available()) {
   
    // read the next key
    char c = keyboard.read();
   
    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
     
      // otherwise, just print all normal characters
      Serial.print(c);
    }
  }
}

chittypoopoo

https://forum.arduino.cc/index.php?topic=235894.0 ?

murf_3

Thanks for the reply, but i have seen that thread and tried the solution of connecting both male and female scanner connections to 5v and ground while only using the male connection for the data and clock lines. I still get the same output of random characters.

Go Up