We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. I am trying to create a sketch that, upon turning a potentiometer hooked up to an arduino, causes 3 different videos to be played, based on what value the potentiometer stops at. I want the arduino to stop taking in sensor data while a video is playing. A lot of strange issues come up, I've attached a screenshot with the majority of errors. The places where it says "error on )" usually indicating a missing parentheses, all parentheses are closed and if i open them back up it still shows an error.
other than this, firmata is uploaded to arduino and testing fine.
Here is the code: Thanks for any help!
import cc.arduino.*;
import org.firmata.*;
import processing.video.*;
import processing.serial.*;
Arduino arduino;
Movie oneDegree;
Movie twoDegrees;
Movie threeDegrees;
int sensor = A0; // select the input pin for the potentiometer
int val = 0;
float value;
void setup() {
size(1920, 1080);
arduino = new Arduino(this, Arduino.list()[0], 57600); //sets up arduino
val = analogRead(sensor); //setup pins to be input (A0 =0?)
oneDegree = new Movie(this, "comp1.mp4");
twoDegrees = new Movie(this, "comp2.mp4");
threeDegrees = new Movie(this, "comp3.mp4");
}
void draw() {
val = analogRead(sensor);
println(val);
if(val <= 348) {
oneDegree.play();
}
else if(348 < val <= 686) {
twoDegrees.play();
}
else if(686 < val <= 1024) {
threeDegrees.play();
}
while( oneDegree.play(), twoDegrees.play(), threeDegrees.play()){
analogRead(sensor) OFF;
}![]()
}
Answers
What Arduino are you using?
Before trying to get your movies playing, you need to ensure your Processing code is interacting properly with your arduino unit. You can start by checking available arduino code from prev posts:
https://forum.processing.org/two/search?Search=arduino
https://forum.processing.org/two/search?Search=firmata
Check for example: https://forum.processing.org/two/discussion/16232/calculating-time-but-expecting-eof-found-switch-why/p1
Notice for example, your like 14 doesn't recognize A0. You need to check the documentation of the libraries that you are using.
Check for example: http://playground.arduino.cc/Interfacing/Processing
Kf
This is not how you write if statements. You need two separate tests ANDed together