We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I have the following code
void draw() {
if ( myPort.available() > 0) { // If data is available,
val = myPort.readString(); // read it and store it in val
v = int(val);
}
println(val);
background(255);
if (v < 700) {
isPaused = false;
myMovie.loop();
scale(2);
image(myMovie, 0, 0);
}
else {
isPaused = true;
myMovie.pause();
blank.updatePixels();
image(blank, 0, 0);
}
if (isPaused) {
blank.updatePixels();
image(blank, 0, 0);
}
else {
scale(2);
image(myMovie, 0, 0);
}
}
My goal would be for the movie to pause when the sensor is sending a value over 700. The println() statement is giving me the proper values, so I know that the Arduino is sending data properly and that Processing is receiving it properly. One thing I tried was putting the code that reads the sensor:
void draw() {
if ( myPort.available() > 0) { // If data is available,
val = myPort.readString(); // read it and store it in val
v = int(val);
}
println(val);
background(255);
if (v < 700) {
isPaused = false;
myMovie.loop();
}
else {
isPaused = true;
myMovie.pause();
}
in a void serialEvent(Serial myPort)
function but then the video began stuttering and the values being received were no longer correct. Any suggestions on what I can do? My other note would be that if I take the sensor code out of the draw loop, I can pause the video and have it all work correctly with mouse events, but when it is in the draw loop the mouse events e.g. mousePressed
do not work.