Hi there,
I'm using an ultrasonic sensor with the arduino so that when a user is a particular distance away from the sensor, processing will then play a video.
All in all there a 4 videos that I want to trigger. I have managed to get the videos to work, but they seem to only follow a set sequence - it will only play a video once and in a set order.
I really need the videos to be played when a user hits that certain distance - more than once so they can walk forwards and backwards away and the videos will play again and again.
I'm pretty new to this so any help is truly grateful as it's for a uni project that's due in this week :/
Like I said, I've managed to code it so that the videos play when a user is a certain distance away from the sensor, I just want them to be able to be played again if the user walks back into the correct range.
Below is my current code:
thanks,
import processing.video.*;
import processing.serial.*;
Serial port;
int val;
Movie oneMovie,twoMovie,threeMovie,fourMovie;
void setup() {
size(displayWidth, displayHeight);
oneMovie = new Movie(this, "blue.mov");
twoMovie = new Movie(this, "orange.mov");
threeMovie = new Movie(this, "green.mov");
fourMovie = new Movie(this, "red.mov");
port = new Serial(this, "/dev/tty.usbmodem1421", 9600);
}
void draw() {
background(0); //Make the background BLACK
image(oneMovie, 0, 0);
image(twoMovie, 0, 0);
image(threeMovie, 0, 0);
image(fourMovie, 0, 0);
val = port.read();
if(val=='1'){
oneMovie.play();
}
if(val=='2'){
twoMovie.play();
}
if(val=='3'){
threeMovie.play();
}
if(val=='4'){
fourMovie.play();
}
}
void movieEvent(Movie m) {
m.read();
}
//make fullscreen
boolean sketchFullScreen() {
return true;
}