-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleapMotionProcessingCode.pde
54 lines (50 loc) · 1.24 KB
/
leapMotionProcessingCode.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
//by Yelenov Amir
import processing.serial.*;
import de.voidplus.leapmotion.*;
LeapMotion leap;
Serial myPort;
void setup() {
size(800, 500);
background(255);
leap = new LeapMotion(this);
println(Serial.list()[0]);
myPort = new Serial(this, "COM3", 9600); //put your arduino port here
}
void leapOnConnect() {
println("I connected!");
}
void draw() {
background(255);
for (Hand hand : leap.getHands()) {
pushMatrix();
float handSize = hand.getSphereRadius();
float yaw = hand.getYaw();
float pitch = hand.getPitch();
if(handSize>125 && yaw > 30 ){
myPort.write(1); // motor is on and hand directs right
println("1");
}
else
if(handSize>125 && yaw < -30 ){
myPort.write(2); // motor is on and hand directs left
println("2");
}
else
if(pitch < -30){
myPort.write(3); // motor is on and hand directs front
println("3");
}
else
if(pitch > 30){
myPort.write(4); // motor is on and hand directs back
println("4");
}
else
if(handSize < 125 ){
myPort.write(5); // motor is off
println("5");
}
println(handSize, yaw);
popMatrix();
}
}