Playing video with a tilt sensor
in
Integration and Hardware
•
2 years ago
Hi all,
I am really new to Processing and have worked with Arduino a little before, so please bear with me on my beginner questions.
I am trying to make a tilt sensor (connected to an arduino) cause a video to start and stop. I've had LOTS of trouble getting a video to load (no idea how to determine image coordinates...it seems really arbitrary), but have managed a somewhat successful video just using basic video loop code.
I downloaded the Arduino library into Processing so I could just download the Firmata sketch onto the Arduino and write code for Processing (instead of writing code for both). It doesn't work, so I'm begging for any guidance on this one. What happens is this: I press run, there is static noise, and the first frame of the movie appears frozen. Then the static stops and the sketch "unexpectedly quits." It happens every time.
My Processing Code:
I'm working on a tight deadline and am BEGGING for any and all help. I'm curious if this has to do with debouncing the tilt switch (it is recommended to do so, btu I had to bypass the code since it's in Processing instead of Arduino).
Thank you in advance for your guidance!
-eb
I am really new to Processing and have worked with Arduino a little before, so please bear with me on my beginner questions.
I am trying to make a tilt sensor (connected to an arduino) cause a video to start and stop. I've had LOTS of trouble getting a video to load (no idea how to determine image coordinates...it seems really arbitrary), but have managed a somewhat successful video just using basic video loop code.
I downloaded the Arduino library into Processing so I could just download the Firmata sketch onto the Arduino and write code for Processing (instead of writing code for both). It doesn't work, so I'm begging for any guidance on this one. What happens is this: I press run, there is static noise, and the first frame of the movie appears frozen. Then the static stops and the sketch "unexpectedly quits." It happens every time.
My Processing Code:
- import processing.serial.*;
import processing.video.*;
import cc.arduino.*;
Movie myMovie;
Arduino arduino;
int inPin = 2; //tilt switch pin
void setup() {
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 115200);
arduino.pinMode(inPin, Arduino.INPUT);
size(1650, 1050);
background(0);
myMovie = new Movie(this, "VID00011test1.mov");
myMovie.speed(1.0);
myMovie.play();
}
void movieEvent(Movie myMovie) {
myMovie.read();
}
void draw() {
background(0);
if (arduino.digitalRead(inPin) == Arduino.HIGH)
myMovie.play();
else
myMovie.stop();
image(myMovie, 200, 206);
}
I'm working on a tight deadline and am BEGGING for any and all help. I'm curious if this has to do with debouncing the tilt switch (it is recommended to do so, btu I had to bypass the code since it's in Processing instead of Arduino).
Thank you in advance for your guidance!
-eb
1