Created
February 2, 2020 16:18
-
-
Save beyazitkolemen/49f18a18644a592cda122295f8d5cfec to your computer and use it in GitHub Desktop.
rdm 6300 multi rfid reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char data1; | |
char data2; | |
String newtag; | |
String newtag2; | |
void setup() { | |
// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin); | |
Serial.begin(115200); | |
Serial2.begin(9600, SERIAL_8N1, 22, 4); | |
Serial1.begin(9600, SERIAL_8N1, 23, 5); | |
} | |
void loop() { //Choose Serial1 or Serial2 as required | |
newtag = ""; | |
newtag2 = ""; | |
while (Serial2.available()) { | |
for (int z = 0 ; z < 14 ; z++) // read the rest of the tag | |
{ | |
data1 = Serial2.read(); | |
newtag += data1; | |
} | |
String msg = newtag.substring(5, 11); | |
long decimal_answer = strtol(msg.c_str(), NULL, 16); | |
Serial.println(msg); | |
Serial.println(decimal_answer); | |
Serial2.flush(); | |
} | |
while (Serial1.available()) { | |
for (int g = 0 ; g < 14 ; g++) // read the rest of the tag | |
{ | |
data2 = Serial1.read(); | |
newtag2 += data2; | |
} | |
String msg2 = newtag2.substring(5, 11); | |
long decimal_answer2 = strtol(msg2.c_str(), NULL, 16); | |
Serial.println(msg2); | |
Serial.println(decimal_answer2); | |
Serial1.flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment