Data visualization with own images

Here what the strucutre of your code could look like:

float sensorValue;

void setup() {
  size(700, 700);
  frameRate(1); 
}

void draw() {
  sensorValue = random(100); //This would be where you read your sensor value instead of getting a random number
  
  if (sensorValue < 10) {
    println("Image1");
  } else if (sensorValue < 50) {
    println("Image2");
  } else {
    println("Image3");
  }
}

In processing the draw function is called over and over and over so the code inside will keep playing over and over.
In the example I constrain the draw function to be launched only one time per second with the frameRate(1); line but otherwise it is called as often as it can.
So what you can do is replace the random line I used to get the value of your sensor. This way it will keep changing depending on what your sensor read.
And since the sensorValue is changing over and over the if…else structure will give a different value over time depending on your sensorValue.

1 Like