Hello Forum!
Im doing a school-project with RFID-tagged Records that trigger different Videos on a screen.
Setup:
Records with RFID-tags
+
RecordPlayer hacked with RFID Reader
+
Arduino Leonardo (sketch: tags assigned to different key-strokes)
+
via USB to Computer
+
HTML5 website key-strokes link to different websites with video
Now my problem:
I have working the RFID hardware and I am reading in the UID (SerialNumber) of the tags and print them to the SerialMonitor.
But Im stuck for now: how to get this number, store it, convert it and compare it in a conditional statement?
(from mySerial.read to ... an array?? ...an if-statement )
I used the following snippet in an other Project to convert an array of HEX numbers into comparable numbers for an if-statement
uint8_t uid[] = { 0, 0, 0, 0 };
uint32_t cardidentifier = 0;
cardidentifier = uid[3];
cardidentifier <<= 8;
cardidentifier |= uid[2];
cardidentifier <<= 8;
cardidentifier |= uid[1];
cardidentifier <<= 8;
cardidentifier |= uid[0];
But I have no clue how to get there...
Here is the code im using in the moment:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
unsigned char command, devnull;
unsigned int returnLength;
void setup()
{
Serial.begin(9600);
Serial.println("Waiting for Card\n");
mySerial.begin(9600);
mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual
}
void loop()
{
if (mySerial.available()) {
Serial.print("\n\rCARD SERIAL: ");
for (unsigned int i=0; i<4 ;i=i){
if (mySerial.available()) {
Serial.print(mySerial.read(),HEX); //Display the Serial Number in HEX
i++;
}
}
mySerial.write(0x02); //Send the command to RFID, please refer to RFID manual
}
}
/*
void Get_Reply() {
while (!mySerial.available());
devnull = mySerial.read();
while (!mySerial.available());
returnLength = mySerial.read() - 1;
for (unsigned int i=0;i< returnLength;i=i){
//Serial.print("2");
if (mySerial.available()) {
//Serial.print("\n\ri is: ");Serial.print(i);Serial.print(" ");
Serial.print(mySerial.read(),HEX); //Display the Serial Number in HEX
Serial.print(" ");
i++;
}
}
}
*/
Thanks in advance for your support!
lg
Markus