okay i tried this and this is the code still comes up as sensor input cannot be resolved as a variable:
//import the Serial library so can read from arudino input via serial communication
import processing.serial.*;
// the number 10 is ASCII for linefeed (end of serial.println),
//later we will look for this to break up individual messages
int end = 10;
String serial; // declare a new string called 'serial'
Serial port; // The serial port, this is a new instance of the Serial class (an Object)
PImage zom;
void setup() {
//serial reading code
// initializing the object by assigning a port and baud rate (must match that of Arduino)
// you may need to change the number in [] to match which serial port your arduino is connected to
port = new Serial(this, Serial.list()[6], 9600);
// function from serial library that throws out the first reading,
// in case we started reading in the middle of a string from Arduino
port.clear();
// function that reads the string from serial port
// until a println and then assigns string to our string variable (called 'serial')
serial = port.readStringUntil(end);
// initially, the string will be null (empty)
serial = null;
size (1000,1000);
zom = loadImage("zom1.jpg");
}
void draw() {
//if there is data coming from the serial port read it/ store it
while (port.available() > 0) {
serial = port.readStringUntil(end);
}
//if the string is not empty, do this
if (serial != null) {
//capsense Input form Arduino, each value is seperated and split depending on the ','
//and then saved in seperate cells of the array so we can access each
String[] SensorInput = split(serial, ',');
//can help to print these to console at this point to check it's working
println(SensorInput);
}
{
if (int(SensorInput[0]) >= 500);
image(zom, 0,0, 500, 500);
background(0);
}
}