Hello, I'm fairly new to processing but have been doing a lot of research for a project I'm working on and have stumbled across a bit of a problem. What I'm trying to do is retrieve information from an arduino and display it on a map. To an extent I've been successful, I am able to get location image to display on the screen but because there are multiple inputs coming in per second the images flicker. I was wondering how I would be able to get it so that when the data reads positive, the image will show on the screen for more than a single frame. I apologize if this doesn't make very much sense, I can explain further if needed. Below is my code:
import processing.serial.*;
Serial myPort;
int val;
PImage img;
void setup()
{
size(2592,1944);
String portName = Serial.list()[0];
println(Serial.list());
myPort = new Serial(this, portName, 9600);
img = loadImage("Bayer (1).jpg");
frameRate(1500);
}
void draw()
{
while (myPort.available() > 0)
{
val = myPort.read();
background(img);
if(val == 1)
{
fill(255,0,0);
rect(900,700,100,100);
}
else if(val == 2)
{
fill(255,0,0);
rect(1260,860,100,100);
}
else if(val == 3)
{
fill(255,0,0);
rect(740,1060,100,100);
}
else if(val == 4)
{
fill(255,0,0);
rect(1120,1240,100,100);
}
else
{
}
}
}