-
Notifications
You must be signed in to change notification settings - Fork 1
/
robot-arm-i-processing.pde
131 lines (107 loc) · 1.97 KB
/
robot-arm-i-processing.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import processing.serial.*;
import controlP5.*;
Serial port;
ControlP5 cp5;
int myColor = color(255);
void setup() {
size(500, 640);
cp5 = new ControlP5(this);
cp5.addSlider("Clamp")
.setPosition(10, 535)
.setWidth(450)
.setHeight(35)
.setRange(50, 160)
.setNumberOfTickMarks(30)
.setSliderMode(Slider.FLEXIBLE)
;
cp5.addSlider("Wrist")
.setPosition(15, 10)
.setSize(55, 500)
.setRange(10, 170)
.setNumberOfTickMarks(55)
;
cp5.addSlider("Elbow")
.setPosition(115, 10)
.setSize(55, 500)
.setRange(10, 130)
.setNumberOfTickMarks(40)
;
cp5.addSlider("Shoulder")
.setPosition(215, 10)
.setSize(55, 500)
.setRange(60, 175)
.setNumberOfTickMarks(35)
;
cp5.addSlider("Base")
.setPosition(10, 585)
.setWidth(450)
.setHeight(35)
.setRange(10, 170) // values can range from big to small as well
.setNumberOfTickMarks(55)
.setSliderMode(Slider.FLEXIBLE)
;
cp5.addButton("Up")
.setValue(90)
.setPosition(300, 10)
.setSize(180, 50)
;
cp5.addButton("Down")
.setValue(175)
.setPosition(300, 80)
.setSize(180, 50)
;
cp5.addButton("ClampClose")
.setValue(160)
.setPosition(300, 150)
.setSize(180, 50)
;
println("Available serial ports:");
println(Serial.list());
port = new Serial(this, Serial.list()[3], 9600);
}
void draw() {
background(35);
}
void Clamp(int val) {
println("Clamp "+val);
port.write(1);
port.write(val);
}
void Wrist(int val) {
println("Wrist "+val);
port.write(2);
port.write(val);
}
void Elbow(int val) {
println("Elbow "+val);
port.write(3);
port.write(val);
}
void Shoulder(int val) {
println("Shoulder "+val);
port.write(4);
port.write(val);
}
void Base(int val) {
println("Base "+val);
port.write(5);
port.write(val);
}
void Up(int val) {
println("Up "+val);
port.write(2);
port.write(3);
port.write(4);
port.write(val);
}
void Down(int val) {
println("Down "+val);
port.write(2);
port.write(3);
port.write(4);
port.write(val);
}
void ClampClose(int val) {
println("ClampClose "+val);
port.write(1);
}