user62091: I am fairly new to processing and Arduino - I have a coursework deadline for both on Monday (6th January). 
I am trying to write a script that uses the mouseX values to turn LEDs on and off. I haven't got any error messages on either of the scripts but currently, nothing happens to the LEDs (they remain off) when I move my mouse. I have tested the circuit with a simpler Arduino code and it is correct so there must be an error in my code!
I would be very grateful for some help. Thanks! 
Processing code:
import processing.serial.*;
Serial port;  
byte lightsOn;

void setup()
{
  size(600,300);
  port=new Serial(this,"/dev/cu.usbmodem1411",9600);
}

void draw()
{
  background(32,78,95);
  rect(300,0,300,300);
  noStroke();
  fill(185,215,216);

  lightsOn=byte(mouseX);
  port.write(lightsOn); 

  println(lightsOn);
}

Arduino code:
#include <Servo.h>

Servo myservo;
int ledpinA=12; 
int ledpinB=13;

void setup() 
{
  Serial.begin(9600);
  myservo.attach(ledpinA&&ledpinB);
  pinMode(ledpinA,OUTPUT);
  pinMode(ledpinB,OUTPUT);
}

void loop()
{
  if(0<Serial.available())
  {
    int data = Serial.read();

  if (data>300)
  {
    digitalWrite(ledpinA, HIGH);
    digitalWrite(ledpinB, LOW);
  }
  else
  {
    digitalWrite(ledpinB, HIGH);
    digitalWrite(ledpinA, LOW);
  }
  }
}


user4143: lightsOn=byte(mouseX);

A byte can be any number from -128 to 127 (Java has no concept of "unsigned" values). The Arduino will reinterpret that as a value from 0 to 255.
if (data>300)

255, the maximum value, can never be more than 300 - so this will always fail.
You need to re-think what data you are sending and how you want to send it.

62091: <p>I am fairly new to processing and Arduino - I have a coursework deadline for both on Monday (6th January). </p>

<p>I am trying to write a script that uses the mouseX values to turn LEDs on and off. I haven't got any error messages on either of the scripts but currently, nothing happens to the LEDs (they remain off) when I move my mouse. I have tested the circuit with a simpler Arduino code and it is correct so there must be an error in my code!</p>

<p>I would be very grateful for some help. Thanks! </p>

<p><strong>Processing code:</strong></p>

<pre><code>import processing.serial.*;
Serial port;  
byte lightsOn;

void setup()
{
  size(600,300);
  port=new Serial(this,"/dev/cu.usbmodem1411",9600);
}

void draw()
{
  background(32,78,95);
  rect(300,0,300,300);
  noStroke();
  fill(185,215,216);

  lightsOn=byte(mouseX);
  port.write(lightsOn); 

  println(lightsOn);
}
</code></pre>

<p><strong>Arduino code:</strong></p>

<pre><code>#include &lt;Servo.h&gt;

Servo myservo;
int ledpinA=12; 
int ledpinB=13;

void setup() 
{
  Serial.begin(9600);
  myservo.attach(ledpinA&amp;&amp;ledpinB);
  pinMode(ledpinA,OUTPUT);
  pinMode(ledpinB,OUTPUT);
}

void loop()
{
  if(0&lt;Serial.available())
  {
    int data = Serial.read();

  if (data&gt;300)
  {
    digitalWrite(ledpinA, HIGH);
    digitalWrite(ledpinB, LOW);
  }
  else
  {
    digitalWrite(ledpinB, HIGH);
    digitalWrite(ledpinA, LOW);
  }
  }
}
</code></pre>
 4143: <pre><code>lightsOn=byte(mouseX);
</code></pre>

<p>A byte can be any number from -128 to 127 (Java has no concept of "unsigned" values). The Arduino will reinterpret that as a value from 0 to 255.</p>

<pre><code>if (data&gt;300)
</code></pre>

<p>255, the maximum value, can never be more than 300 - so this will <em>always</em> fail.</p>

<p>You need to re-think what data you are sending and how you want to send it.</p>
