Hi everyone ,
In my code I am trying to pass the value of int node1, node2, node3 in texts as you can see in void draw.
import java.util.Arrays;
import processing.serial.*;
import http.requests.*;
PImage bg;
int address;
int value;
String read;
String list;
String hex;
int node1;
int node2;
int node3;
int lf = 10;
Serial COMPort;
String[] validaddresses={"0x1","0x2","0x3","0x4"};
void setup() {
size(1280, 720);
bg = loadImage("some photo.jpg");
String portName = Serial.list()[0];
COMPort = new Serial(this, portName, 9600);
COMPort.bufferUntil(lf);
textSize(30);
}
void draw() {
background(bg);
int node1=0;
int node2=0;
int node3=0;
text("The value is " + node1, 250, 250);
text("The value is " + node2, 450, 350);
text("The value is " + node3, 450, 450);
}
void serialEvent(Serial COMPort)
{
read = trim(COMPort.readString()); // read and store it to string read
String[] list=split(read," ");
if (list[0].equals(validaddresses[0])) {
int node1 = Integer.parseInt(list[1]);
System.out.println(node1);
}
if (list[0].equals(validaddresses[1])) {
int node2 = Integer.parseInt(list[1]);
System.out.println(node2);
}
if (list[0].equals(validaddresses[2])) {
int node3 = Integer.parseInt(list[1]);
System.out.println(node3);
}
delay(100);
}
Is there an easy way to solve with this issue? Not sure what I have to try.