Screen Shot 2022-12-02 at 10.26.49 PM.png

Screen Shot 2022-12-02 at 10.26.59 PM.png

Exploring with the arguments in the linear gradient function, I found that the startX and endX values change the ratio of colors within the gradient.

IMG_8173 2.heic

To change the color ratio, if the toggle is set to high or to color1, startX will be changed. If the toggle is low or set to color2, endX is changed. Pressing the left FSR will subtract 20, while pressing the right FSR will add 20.

However, endX has to be greater than 0.

Screen Shot 2022-12-02 at 10.27.39 PM.png

Screen Shot 2022-12-02 at 10.27.43 PM.png

And, startX has to be less than 400 or width.

Screen Shot 2022-12-02 at 10.27.58 PM.png

Screen Shot 2022-12-02 at 10.28.05 PM.png

Having previously worked with FSRs before, I programed IDE to print the FSR values.

int rightFSR_VALUE = analogRead(A2);
  int leftFSR_VALUE = analogRead(A3);

  Serial.print("RIGHT:");
  Serial.print(rightFSR_VALUE);
  Serial.print(", ");
  Serial.print("LEFT:");
  Serial.print(leftFSR_VALUE);
  Serial.print(", ");
  Serial.println(toggleSwitch1_STATE);

Untitled

Updated information being sent to p5:

if (Serial.available() > 0) {
    int inByte = Serial.read();
  
    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.print(bright2);
    Serial.print(", ");

    Serial.print(leftFSR_VALUE);
    Serial.print(", ");
    Serial.print(rightFSR_VALUE);
    Serial.print(", ");
    Serial.println(toggleSwitch1_STATE);
  
  delay(100);
  }
function serialEvent() {
  inString = serial.readStringUntil("\\r\\n");
  if (inString != null) {
    console.log(inString);
    let colr = split(trim(inString), ",");
    console.log(colr);
    if (colr.length == 9) {
      hu1 = Number(colr[0]);
      sat1 = Number(colr[1]);
      bright1 = Number(colr[2]);
      hu2 = Number(colr[3]);
      sat2 = Number(colr[4]);
      bright2 = Number(colr[5]);
      
      leftFSR = Number(colr[6])
      rightFSR = Number(colr[7])
      toggle1 = Number(colr[8])
      serial.print("x");
    }
  }
}

I set the starting parameters to be 1 interval of 10 plus 1 value for startX or sX and 1 interval of 10 minus 1 for endX or eX.

let leftFSR, rightFSR;
let sX = 11;
let eX = 389;
let toggle1;