Read RFID Card Number in Processing over Serial I have successfully setup up a RFID reader with Arduino Uno and EM-18 Card Reader Module.

Its program for Arduino is below:

int count = 0; // count = 0

char input[12];                                         // character array of size 12

boolean flag = 0;                                       // flag =0

void setup()
{
   Serial.begin(9600);                                  // begin serial port with baud rate 9600bps
}

void loop()
{
   if(Serial.available())

{

count = 0;

while(Serial.available() &amp;&amp; count &lt; 12)          // Read 12 characters and store them in input array

{
input[count] = Serial.read();
count++;
delay(5);
}

//Serial.print("Card ID - ");

Serial.print(input);      // Print RFID tag number 


}

}


But when try to read the code over serial in the program for locking/unlocking mouse in Processing the values of strings don't match.
Hence the mouse doesn't get unlocked.

The program for processing is as below:

import processing.serial.*;
import java.awt.AWTException;
import java.awt.Robot;

Robot robot;
boolean locked = false;
Serial port;
void setup()
{
  println(Serial.list()); //Prints available ports

  port = new Serial(this, Serial.list()[36], 9600); //Chooses the first available port
  try
  {
    robot = new Robot(); //Creates robot
  }
  catch (AWTException e)
  {
    e.printStackTrace();
  }
}

void draw()
{
  if (locked == true) robot.mouseMove(0, 0); //If locked, moves mouse to top left corner
  while (port.available() &gt; 0)
  {
    String input = port.readString(); 
    //println(input);
    if (input.equals("11006F26DC84") == true) locked = false; //If it read my card it will unloack.
  }
}

void keyPressed ()
{
  if (key == 'l')
  {
    locked = true; //Locks it
  }

  if (key == 'u')
  {
    locked = false; //Unlocks it
  }

  if (key == ESC)
  {
    key = 0; //Disables escape as quit
  }
} 


Please point the incorrect syntax and suggest correct one.
input has to be 13 characters in size; you forgot to include a byte for the null-terminator. Then right before Serial.print(input), you write input[12] = 0. Also the argument to string.equals() should be a String as well; you must write the statement like this: input.equals(String("11006F26DC84"));