-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_tracking_display.pde
More file actions
88 lines (62 loc) · 1.34 KB
/
Copy pathobject_tracking_display.pde
File metadata and controls
88 lines (62 loc) · 1.34 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import processing.serial.*;
Serial myPort;
int angle = 0;
int distance = 0;
void setup() {
size(1000, 700);
println(Serial.list());
// Change COM5 if needed
myPort = new Serial(this, "COM5", 9600);
myPort.bufferUntil('\n');
}
void draw() {
background(0);
translate(width/2, height-50);
// Radar circles
stroke(0,255,0);
noFill();
arc(0,0,800,800,PI,TWO_PI);
arc(0,0,600,600,PI,TWO_PI);
arc(0,0,400,400,PI,TWO_PI);
arc(0,0,200,200,PI,TWO_PI);
// Radar sweep line
strokeWeight(3);
line(
0,
0,
400*cos(radians(angle)),
-400*sin(radians(angle))
);
// Target point
if(distance > 5 && distance < 100){
stroke(255,0,0);
strokeWeight(10);
float r = distance * 4;
point(
r*cos(radians(angle)),
-r*sin(radians(angle))
);
}
// Text
fill(0,255,0);
textSize(25);
text("Angle : " + angle, -450, -600);
text("Distance : " + distance + " cm", -450, -560);
if(distance > 5 && distance <= 20){
fill(255,0,0);
textSize(30);
text("TARGET DETECTED", -450, -500);
}
}
void serialEvent(Serial myPort) {
String data = myPort.readStringUntil('\n');
if(data != null){
data = trim(data);
println(data);
String[] values = split(data, ',');
if(values.length == 2){
angle = int(values[0]);
distance = int(values[1]);
}
}
}