Hello,
I am trying to hook up my magnetic card reader to my Arduino Uno and display the data into the serial terminal or store in a variable. The mag reader I purchased is located here Magnetic Card Reader - SEN-11096 - SparkFun Electronics
and it comes with a PS/2 male and female and a RS 232 female connectors. I have no idea which connectors I should use, but I decided to go with the female PS/2. (Please let me know if this is a bad decision)
Currently I have cut of the female PS/2 and stripped the wires back to see
BLACK,RED,GREEN,WHITE.
I know that BLACK = gnd, RED = 5v, GREEN and WHITE must be clock and data? vice versa?
My sketch (not really mine) compiles while using the PS/2 library. The latest lib I found is PS2Keyboard (version 2.4) found here https://github.com/PaulStoffregen/PS2Keyboardl along with the example sketch I have been using found here PS2Keyboard Library, Connect a keyboard for user input, also seen below.
#include <PS2Keyboard.h>
const int DataPin = 5;
const int IRQpin = 8;
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);
Serial.println("Keyboard Test:");
}
void loop() {
if (keyboard.available()) {
Serial.println("WORKING");//to see if statement is runninf DEBUGING
// 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);
}
}
}
I just can't seem to get any output. I have done some debugging and I don't think the if statement keyboard.available() is even running. Therefore the sketch isn't picking up the magnetic reader??? I really don't know. If I had to guess, it's probably because I used the wires from the female PS/2 and not male, but I have no clue.
Please let me know if anyone needs more information to solve this problem.
Thanks so much in advance,
Zeta