Hi @Mirzohid
Regarding your first question, yes it is possible. You either send the two values on the same Serial port or you use two Serial Ports each sending the data from one photoresistor. It depends on your electronic setup.
If you choose to send the two photoresistors state over the same Serial port, you can then, split the information and assign them to your variables.
This is a quick example that I have found in a processing forum to illustrate.
(Receive Multiple Sensor Information from Arduino to Processing - Processing 2.x and 3.x Forum)
There are multiple ways to do send the data. So, take the time to investigate as well
Since your values go from 0 to 255 (I am guessing that you are using analogRead), then you can send one byte per photoresist (byte / Reference / Processing.org), or as Strings in the example above.
If you choose to connect two serial ports, then you will have to identify which port is sending the values. So, you will need to create two Serial Port Objects, assign the Ports and baud rate, and on the Serial Event identify which one is sending data.
Something like this,
import processing.serial.*;
Serial portOne; // Create object from Serial class
Serial portTwo;
void setup() {
size(400, 400);
//Make sure that you are not assign the same COM port to the two Serial objects. Also, the baud rate should be the same!
portOne = new Serial(this, "COM3", 9600);
portTwo = new Serial(this, "COM4", 9600);
}
void serialEvent(Serial thisPort) {
if(thisPort==portOne){
//...GOOD NEWS: data from serial 1
}
if(thisPort==portTwo){
//...GOOD NEWS: data from serial 2
}
}
Once again, take the time to look for resources
Below are some links that I think will be helpful to you in the future
Handshake Protocol
Best regards!