i try to have the serial port print out"red,yellow or blue" when the rfid read a tag but i doesn't seem to work, can anyone help me?
The rfid is RDM6300 UART
This is the code
int readVal = 0; // individual character read from serial
unsigned int readData[10]; // data read from serial
int counter = -1; // counter to keep position in the buffer
char tagId[1]; // final tag ID converted to a
//////RFID///////
const int NUMBER_OF_TAGS = 27;
String tags[NUMBER_OF_TAGS] = {
//1do//
"0E0078F577",
"0E00791C23" ,
"0E007B55D7" ,
"0E00790AD5" ,
"0E007932D3",
"0E007B577E",
"0E0079476E",
"0E0079EE74",
"0E007956BF",
"0C002467F1" ,
//2vang//
"0E0079B9CC",
"0E002E1647",
"0E0079C305",
"0E007C6055",
"0C0028A5A2",
"0E002F6D7A",
"0E007BE683",
"0E0078CC9E",
"0E00793C9A",
///3xanh///
"0D002F32D1",
"0C0034389E",
"0E0031FD73",
"0E007C1EAB",
"0E002D77E7",
"0C00283412",
"0C00346C97",
"0E007BB1D8"
};
int types[NUMBER_OF_TAGS] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
void setup() {
Serial.begin(9600);
}
void parseTag() {
int i;
for (i = 0; i < 10; ++i) {
tagId = readData*;*
* }*
* tagId[10] = 0;*
}
* void checktagcolor() {*
* String tagId = "";*
for (int i =0; i < NUMBER_OF_TAGS; ++i) {
_ if (tagId == tags*) {
if (types == 1) {
Serial.println("Red");
}
else if(types == 2) {
Serial.println("Yellow");
}
else if (types == 3) {
Serial.println("Blue");
}
}
}
}
void processTag() {
// convert id to a string*
* parseTag();*_
* // print it*
* printTag();*
* ////checkcolor////*
* checktagcolor();*
}
void printTag() {
* Serial.print("Tag value: ");*
* Serial.println(tagId);*
}
void clearSerial() {
* while (Serial.read() >= 0) {*
* ; // do nothing*
* }*
}
void loop() {
if (Serial.available() > 0) {
* // read the incoming byte:*
* readVal = Serial.read();*
* // a "2" signals the beginning of a tag*
* if (readVal == 2) {*
* counter = 0; // start reading*
* } *
* // a "3" signals the end of a tag*
* else if (readVal == 3) {*
* // process the tag we just read*
* processTag();*
* // clear serial to prevent multiple reads*
* clearSerial();*
* // reset reading state*
* counter = -1;*
* }*
* // if we are in the middle of reading a tag*
* else if (counter >= 0) {*
* // save valuee*
* readData[counter] = readVal;*
* // increment counter*
* ++counter;*
* }*
* }*
}