Serial communication RFID reader to Processing

RFID reader
The Lab has a number of readers from Sparkfun which can be easily hooked up to a computer via mini-USB.

Processing code to receive:

import processing.serial.*;

Serial rfidPort;
String currentTag = "";

String authorizedTag = "01023C1DCAE8"; // Replace with your RFID tag ID

void setup() {
size(400, 200);

println(Serial.list()); // Show available serial ports

// Change the index to match the USB-port for your RFID reader
rfidPort = new Serial(this, Serial.list()[3], 9600);

// Trigger serialEvent() when a newline is received
rfidPort.bufferUntil('\n');
}

void draw() {
//in this example, nothing happens here
background(240);
}

void serialEvent(Serial port) {

currentTag = port.readStringUntil('\n');

if (currentTag != null) {

// Removing whitespace, CR, LF characters
currentTag = trim(currentTag);

println("Tag detected: " + currentTag);

if (currentTag.equals(authorizedTag)) {
println("I know this one!");
}
else {
println("Never seen this one!");
}
}
}


;