Here is my code so far
#include <SoftwareSerial.h>
#define BUFFSIZ 90
//RFID parser
char buffer_RFID[BUFFSIZ];
char buffidx_RFID;
char response_str[64];
char command_scantag[] = {0x43,0x04,0x01,0xCD};
char command_firmware[] = {0x10,0x03,0x00}; // Command to get firmware version
char command_antenna[] = {0x18, 0x03, 0xFF};
unsigned char incomingByte;
unsigned char inByte;
unsigned char numTags;
unsigned char parsed_okay = 0;
unsigned char tag_found_number;
unsigned int bytecount = 0;
SoftwareSerial mySerial(2,3); // RX, TX
void setup() {
parsed_okay = 0;
Serial.begin(9600); // Start serial monitor
mySerial.begin(9600); // Serial port for UHF RFID scanner
Serial.println("Initialize");
mySerial.print(command_antenna[0]);
mySerial.print(command_antenna[1]);
mySerial.print(command_antenna[2]);
while(mySerial.available()) {
inByte = mySerial.read();
Serial.println(inByte, DEC);
}
}
void loop() {
while(Serial.available())
{
incomingByte = Serial.read(); // Read input from serial monitor
if(incomingByte == 'r')
{
Serial.println("Start read");
mySerial.print(command_scantag[0]);
mySerial.print(command_scantag[1]);
mySerial.print(command_scantag[2]);
mySerial.print(command_scantag[3]);
parsed_okay = 0;
bytecount = 0;
}
}
while(mySerial.available()) {
inByte = mySerial.read();
Serial.println (inByte, HEX);
bytecount++;
if(bytecount == 3) {
Serial.println(inByte,HEX);
}
}
}
This is using a Cottonwood RFID long range reader. I am new to programing and this is over my head. What I think should be an easy fix is not. I can get the reader to read the cards but only when I send R using the serial monitor. What do I need to change to get it to continue reading without me doing anything? Finally once it does read a tag I need it to compare it to a list of tags and if it is the same as that one to turn on an LED.
Here is what the serial monitor shows
Initialize This is when I load the serial monitor
19
3
0
0
Start read right after I send "r" with now card
44
5
0
0
0
0
Start read Right after I send "r" with a card
44
16
1
1
CE
FC
37
D
E
30
0
30
35
30
7B
28
31
B3
82
10
BE
63
6B
