Via Processing eine LED an-/ausschalten

Klickt man bei Processing auf den Bildschirm, leuchtet am Arduino so lange die LED, wie die Mousetaste gedrückt ist.
Arduino
// https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing
// ACHTUNG: Der Serial-Monitor von Arduino muss geschlossen sein
// sonst funktioniert die Kommunikation mit Processing nicht!
// andersrum muss das Processing-Applet beendet sein, bevor man wieder etwas auf den Arduino hochladen kann
int ledPin = 13;
char val; // Data received from the serial port
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) { // If data is available to read,
val = Serial.read(); // read it and store it in val
}
if (val == '1') { // If 1 was received
digitalWrite(ledPin, HIGH); // turn the LED on
} else {
digitalWrite(ledPin, LOW); // otherwise turn it off
}
delay(10); // Wait 10 milliseconds for next reading
}
Processing
// ACHTUNG: Der Serial-Monitor von Arduino muss geschlossen sein
// sonst funktioniert die Kommunikation mit Processing nicht!
// https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing
import processing.serial.*;
Serial myPort; // Create object from Serial class
void setup() {
size(440, 440);
frameRate(10);
// Abfrage aller Ports, hier sollte der gleiche Port auftauchen, den Ihr bei Arduino verwendet!
printArray(Serial.list());
String arduinoPort = Serial.list()[5];
myPort = new Serial(this, arduinoPort, 9600);
}
void draw() {
if (mousePressed == true) {
myPort.write('1'); //send a 1
println("1");
background(255, 0, 0);
} else {
myPort.write('0'); //send a 0
background(255);
}
}