Hi,
I have the PS/2 version of the Adafruit MCR12 barcode scanner
Im connecting it to an Arduino Mega with this adapter cable
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.
#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);
}
}
}