I sent the two separate sets of HSB values to p5.
int toggleSwitch1_STATE = digitalRead(toggleSwitch1_PIN);
if(toggleSwitch1_STATE == HIGH) {
HSB1 = stick.ColorHSV(ringHue, saturation, brightness);
stick.fill(HSB1, 0, 4);
stick.fill(0, 4, 4);
hu1 = map(position, 0, 24, 0, 360);
sat1 = map(sliderPot1_VALUE, 0, 1023, 0, 100);
bright1 = map(sliderPot2_VALUE, 0, 1023, 0, 100);
}
if (toggleSwitch1_STATE == LOW) {
HSB2 = stick.ColorHSV(ringHue, saturation, brightness);
stick.fill(HSB2, 4, 4);
stick.fill(0, 0, 4);
hu2 = map(position, 0, 24, 0, 360);
sat2 = map(sliderPot1_VALUE, 0, 1023, 0, 100);
bright2 = map(sliderPot2_VALUE, 0, 1023, 0, 100);
}
stick.show();
Serial.print(hu1);
Serial.print(",");
Serial.print(sat1);
Serial.print(",");
Serial.print(bright1);
Serial.print("; ");
Serial.print(hu2);
Serial.print(",");
Serial.print(sat2);
Serial.print(",");
Serial.println(bright2);
delay(500);
function serialEvent() {
inString = serial.readStringUntil("\\r\\n");
if (inString != null) {
console.log(inString);
let colr = split(trim(inString), ",");
console.log(colr);
if (colr.length==6) {
pos1 = Number(colr[0]);
sat1 = Number(colr[1]);
bright1 = Number(colr[2]);
pos2 = Number(colr[3]);
sat2 = Number(colr[4]);
bright2 = Number(colr[5]);
serial.print('x');
}
}
}
I filled two rectangles with the different HSB values.
fill(hu1, sat1, bright1);
rect(50, 150, 100, 100);
fill(hu2, sat2, bright2);
rect(250, 150, 100, 100);
I was able to successfully change one rectangle color without changing the other rectangle color.