import processing.serial.*;

Serial myPort;  
int val;     
int sensorData; 
int highVal; 
int lowVal; 
int actualVal;  

void setup() 
{
  size(200, 200);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}

void draw()
{
  if (myPort.available() > 0) {    
    val = myPort.read();           
    if (val > 4) {                
      highVal = myPort.read();           
      lowVal = myPort.read();           
      actualVal = 256 * (highVal + lowVal); 
      println("The actualVal is " + actualVal); 
    }

    background(255);             
    if (actualVal < 1024) {    
      fill(0);                   
    } 
    else {                       
      fill(204);                 
    }
    rect(50, 50, 100, 100);
  }
}