Varier la luminosité d'une led avec arduino et processing

Bonjour, je suis actuellement en terminal, et je suis bloqué sur mon travail. J'ai une interface graphique réalisée sur processing, qui sert de gradateur de lumière, j'ai de même un programme arduino permettant de varier la luminosité de la led grâce à un capteur de lumière : plus j'avance ma main du capteur, et plus la led s'allume. J'aimerais activer un mode "manuel" en faisant varier la luminosité (en %) de la led sur processing grâce au gradateur. Je suis vraiment bloqué et demande de l'aide, voici mes programmes ci-dessous, meilleures salutations.

Arduino :

const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int ledPin = 6; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 255, 0, 1023, 0);
// change the analog out value:
analogWrite(ledPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}

Processing :

void setup() {
size(1050, 500, P3D);
noStroke();
colorMode(RGB, 1);
fill(0.4);
}

void draw() {
background(0);
text("0", 0, 450);
text("10", 100, 450);
text("20", 200, 450);
text("30", 300, 450);
text("40", 400, 450);
text("50", 500, 450);
text("60", 600, 450);
text("70", 700, 450);
text("80", 800, 450);
text("90", 900, 450);
text("100", 1000, 450);
rect(100,100,100,100);
text("Manu/Auto",116,98);
translate(width / 2, height / 2);
// Set the specular color of lights that follow
lightSpecular(1, 1, 1);
directionalLight(0.8, 0.8, 0.8, 0, 0, -1);
float s = mouseX / float(width);
specular(s, s, s);
sphere(120);
}