Hello, I'm a total newbie of arduino user
I have a project in university about magnetic card reader for student absent
my magnetic card reader is using output usb, and when I plug in into computer and swipe the card, the data will show on where the cursor is
but i have to make it portable, so i connected it to my arduino uno.
I connected the MCR using the usb-b to usb mini cable, FTDI USB to UART converter FT232RL, and the tx rx to my arduino uno. so the connection is like this:
MCR(USB)>>USB-B to USB mini cable>>USB to UART converter>>ARDUINO UNO
I'm trying to read the serial data from MCR here, I think it's just as simple as mcr.read(), but it's not. I've tried to get the data with many source code, and my deadline is in 2 days. can anyone help me please? here is my source code, I'm using serial event because I think that is the most logical code to read the data.
#include <SoftwareSerial.h>
String inputString = "";
boolean stringComplete = false;
SoftwareSerial mcr (2,3); // tx ftdi to pin 2 rx to pin 3
void setup() {
Serial.begin(9600);
mcr.begin(9600);
inputString.reserve(200);
}
void loop() {
if (stringComplete) {
Serial.println(inputString);
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (mcr.available()) {
char inChar = (char)mcr.read();
inputString += inChar;
if (inChar == '?') { //my mcr data is ;5555555?
stringComplete = true;
}
}
}
anyone please help me