Trigger videos with captors


We are using an arduino board but we are coding with processing.

We are using magnetic sensors to trigger videos and it works except that processing displays each video on top of one another. And it is a problem because when we trigger a captor that we have already triggered we can't see the video because it is under the other.

And I guess it makes sense because the image are displayed in the "voiddraw" on top of one another

  image(myMovie, 0, 0, 1280, 720);
  image(myMovie2, 0, 0, 1280, 720);
  image(myMovie3, 0, 0, 1280, 720);

but we really don't know how to make it work differently. And if we put them in the "if" the video doesnt work if the captor is low.

I don't know if we make any sense, sorry. Here is the code:

import processing.serial.*;
import cc.arduino.*;

Movie myMovie;
Movie myMovie2;
Movie myMovie3;

int MS0 = 11; 
int MS1= 10;
int MS2= 9;

Arduino arduino;

void setup() {
  myMovie = new Movie(this, "C:\\Users\\Charlotte\\Desktop\\blop.mp4");
  myMovie2 = new Movie(this, "C:\\Users\\Charlotte\\Desktop\\blop2.mp4");
  myMovie3 = new Movie(this, "C:\\Users\\Charlotte\\Desktop\\blop3.mp4");

  arduino = new Arduino(this, Arduino.list()[2], 57600);

  arduino.pinMode(MS0, Arduino.INPUT);
  arduino.pinMode(MS1, Arduino.INPUT);
  arduino.pinMode(MS2, Arduino.INPUT);


void draw() {

  image(myMovie, 0, 0, 1280, 720);
  image(myMovie2, 0, 0, 1280, 720);
  image(myMovie3, 0, 0, 1280, 720);

  if (arduino.digitalRead(MS0) == Arduino.HIGH) {
  else if (arduino.digitalRead(MS1) == Arduino.HIGH || arduino.digitalRead(MS2) == Arduino.HIGH) {

  if (arduino.digitalRead(MS1) == Arduino.HIGH) {
  } else if (arduino.digitalRead(MS0) == Arduino.HIGH || arduino.digitalRead(MS2) == Arduino.HIGH) {

  if (arduino.digitalRead(MS2) == Arduino.HIGH ) {
  }else if (arduino.digitalRead(MS1) == Arduino.HIGH || arduino.digitalRead(MS0) == Arduino.HIGH) {


void movieEvent(Movie m) {;

That question would be better asked on the Processing forum.

I am not that familiar with Processing, but since myMovie, myMovie2 and myMovie3 look like they are all just Movie objects, you should be able to just define another generic activeMovie object and do all your processing with it. So when you detect a new sensor has moved to the HIGH state, you would do

activeMovie.stop(); // stop whatever movie is currently active
activeMovie=myMovieX; // change the active movie object to myMovie or myMovie2 or myMovie3 object
activeMovie.loop(); //start playing the new active movie

then outside the if statements you could do something generic like...

image(activeMovie, 0, 0, 1280, 720); //draw generic movie object

Of course you would need to initialize the activeMovie object with one of the three to start. This is just a best guess. Hope it helps.

Yeah it helped, thank you a lot!