-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToante.pde
60 lines (50 loc) · 1.27 KB
/
Toante.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import processing.serial.*;
import cc.arduino.*;
import processing.video.*;
Arduino arduino;
Movie video;
color off = color(4, 79, 111);
color on = color(84, 145, 158);
int pin_sensor = 2;
int count = 0;
int r = 0;
int movimento = 0; // 0 -> normal, 1 -> vertical, 2->
final int n_frames_movimento = 70;
void setup() {
size(480, 720);
// Configuração Arduino
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(pin_sensor, Arduino.INPUT);
// Configuração do video
video = new Movie(this, "toante.mov");
video.loop();
}
void draw() {
//background(off);
//stroke(on);
pushMatrix();
if( r > 0 ){
r -= 1;
if(movimento == 1){
scale(-1, 1);
image(video, -width, 0, width, height);
} else if (movimento == 2) {
scale(1, -1);
image(video, 0, -height, width, height);
} else {
image(video, 0, 0, width, height);
}
} else if (arduino.digitalRead(pin_sensor) == Arduino.LOW){
r = n_frames_movimento;
movimento = (movimento + 1)%3; // (0 + 1)%2 = 1, (1+1)%2 = 0
} else {
// Não tem movimento. Video normal.
image(video, 0, 0, width, height);
}
rect(420 - pin_sensor * 30, 30, 20, 20);
popMatrix();
}
void movieEvent(Movie m) {
m.read();
}