We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Interactive event within draw()
Page Index Toggle Pages: 1
Interactive event within draw() (Read 404 times)
Interactive event within draw()
Dec 1st, 2009, 5:30am
 
Hi there

Am at the moment trying to understand how to *play a video* only when force from arduino.analogRead(0) receives input and the if else statement stops (or should) video when nothing happening.

At the moment the input stops at original position of potentiometer, otherwise event continues.

I'm unsure as to what's going wrong: have tried using different boolean operators & am considering using a for loop, could this be worth while?

thanks
Calum


Code:


void draw() {

println(arduino.analogRead(0));
if(arduino.analogRead(0) != curInput){
i++;
fill(0,0,0,i); //i is used for transperancy
rect(0,0,width,height);
if (i > 60) {
i = 0;
}
image(theMov, 0, 0);
//println("RING BELL");
}
// else if (curInput == arduino.analogRead(0)) {
else if(arduino.analogRead(0) == arduino.analogRead(0)) {
i++;
fill(255,255,255,i); //i is used for transperancy
rect(0,0,width,height);
if (i > 60) {
i = 0;
}
theMov.stop();
theMov.loop();
}
}


Page Index Toggle Pages: 1