Help Help !
in
Integration and Hardware
•
5 months ago
Hello guys, Im a beginner. I wanna create a delay in processing. I tried my best to make a similar one however it didn't work well.
Here's my code.
import processing.serial.*;
import cc.arduino.*;
import ddf.minim.*;
Arduino arduino;
Minim minim;
AudioOutput out;
AudioPlayer song;
int sensorValue;
int k,pk;
int l=0;
int t=1;
void setup() {
arduino = new Arduino(this, Arduino.list()[1], 57600);
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.INPUT);
arduino.pinMode(12, Arduino.OUTPUT);
size(400,500);
minim = new Minim(this);
song = minim.loadFile("1.mp3");
}
void draw() {
pk=k;
k=second();
sensorValue = arduino.analogRead(0);
sensorValue = sensorValue/4;
println(sensorValue);
if(t==0){
song.pause();
if(((k-pk)==1))
l++;
arduino.digitalWrite(12,Arduino.LOW);}
println(l);
if (arduino.digitalRead(2) == Arduino.HIGH) {
t=0;
l=0;
}
if(l==4){
song.rewind();
Here,the song will suddenly play at l3 then starts again at l4. Don't know how to deal with it.
t=1;
l=0;
}
if(t==1){
arduino.digitalWrite(12,Arduino.HIGH);
song.play();
}
}
void stop() {
song.close();
minim.stop();
super.stop();
}
How can I fix this?
Thanks a lot.
(and sorry for my awful english)
1