There was a lot wrong with this code... I had done this long ago and a few computer crashes back... I dont know what version of processing I was using but it didn't seem so difficult before. The ah ha moment came when I figured out that the slider calls a subroutine that hopefully does what you want.
I had another snag in that red blue and green seemed to be predefined as floats or something other than integer which is what you need to write to the PWM output of the arduino. I had originally named my sliders red blue and green.
Another thing that is confusing is that your slider can be named Red and the variable for the slider value can be Red as well. Probably not the best idea but doable as is a slider named slider as was the case in one of the examples.
At any rate I got it working and here is the updated code for those that may be interested.
import processing.serial.*;
import cc.arduino.*;
import controlP5.*;
ControlP5 cp5;
Arduino arduino;
void setup() {
size(700, 400);
noStroke();
cp5 = new ControlP5(this);
println(Arduino.list()); // Prints out the available serial ports.
// Modify this line, by changing the "0" to the index of the serial
// port corresponding to your Arduino board (as it appears in the list
// printed by the line above).
arduino = new Arduino(this, Arduino.list()[2], 57600);
cp5.addSlider("Red")
.setPosition(50,150)
.setSize(512,20)
.setRange(0,255)
;
cp5.addSlider("Green")
.setPosition(50,200)
.setSize(512,20)
.setRange(0,255)
;
cp5.addSlider("Blue")
.setPosition(50,250)
.setSize(512,20)
.setRange(0,255)
;
}
void draw() {
background(128);
}
// Output analog values (PWM waves) to digital pins 3, 5, 6
// Note that only certain Arduino pins support analog output (PWM).
// See the documentation for your board for details.
// needs to be integer 0 - 255
void Red(int Red) {
arduino.analogWrite(5, Red);
println ("PWM Red is " +Red);
}
void Green(int pwm_g) {
arduino.analogWrite(3, pwm_g);
println ("PWM Green is " +pwm_g);
}
void Blue(int pwm_b) {
arduino.analogWrite(6, pwm_b);
println ("PWM Blue is " +pwm_b);
}