Hello, I am not very advanced in Arduino and I have never used the forum, but I am using an RFID UART module through GROVE on a seeeduino shield on my Arduino Uno. I have code that works and outputs an unsigned char array of numbers that it has read from the RFID chip. it shows it in the serial as such: 4100605A166D. And now I want to be able to say, if it reads 4100605A166D Serial.write A B or C, so I can use that in processing. But I just don't know how to start checking which chip it is scanning.
#include <SoftwareSerial.h>
SoftwareSerial SoftSerial(2, 3);
unsigned char buffer[64]; // buffer array for data receive over serial port
int count = 0; // counter for buffer array
void setup()
{
SoftSerial.begin(9600); // the SoftSerial baud rate
Serial.begin(9600); // the Serial port of Arduino baud rate.
}
void loop()
{
// if date is coming from software serial port ==> data is coming from SoftSerial shield
if (SoftSerial.available())
{
while (SoftSerial.available()) // reading data into char array
{
buffer[count++] = SoftSerial.read(); // writing data into array
if (count == 64)break;
analogWrite(3, 0);
}
Serial.write(buffer, count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the stored data from the array
count = 0; // set counter of while loop to zero
}
}
void clearBufferArray() // function to clear buffer array
{
// clear all index of array with command NULL
for (int i = 0; i < count; i++)
{
buffer[i] = NULL;
}
}
This is my code. I am aware the data is stored in buffer but I don't know how to compare it to a pre defined array or string, idk.
thanks in advance