-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathArm.ino
307 lines (249 loc) · 4.94 KB
/
Arm.ino
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#include <Stepper.h>
/*
-ve for down
+ve for up
+ve anticlockwise
-ve clockwise
*/
#define WATER 11 * 15 // flame 1
#define OIL 15 * 15 // flame 2
#define NON_KNIFE 1 * 15 // source1
#define KNIFE 19 * 15 + 15 // source 2
#define SERVEWATER 7 * 15 // deliver 1
#define A2LB 9 * 15
int length_of_move = 5;
int stepsPerRevolution = 200;
int PAN_LENGTH = length_of_move * stepsPerRevolution - 30;
int GROUND_LENGTH = length_of_move * stepsPerRevolution + 60;
int A2LB_LENGTH = length_of_move * stepsPerRevolution - 205;
int NON_KNIFE_HEIGHT = length_of_move * stepsPerRevolution - 40; // source1 height Doneeee
int KNIFE_HEIGHT = 200; // source 2 heigth
int deleiverHeight = length_of_move * stepsPerRevolution - 140; // Done
int i;
int Current_Location = 0;
Stepper ARM(stepsPerRevolution, 6, 7, 8, 9);
Stepper Base(stepsPerRevolution, 5, 4, 3, 2);
// read the from the bm
uint8_t x;
uint8_t read_input()
{
if (Serial.available() > 0)
{
x = Serial.read() - 48;
return 1;
}
else
return 0;
}
void setup()
{
// set the speed at 60 rpm:
ARM.setSpeed(5 0);
Base.setSpeed(10);
// initialize the serial port:
Serial.begin(9600);
emsk(GROUND_LENGTH);
}
int read;
void loop()
{
// uint8_t y = read_input();
// if (y) {
// Serial.println(x);
// Arm(x);
// }
}
void testEmsk()
{
emskNonKnife();
fixHeigth();
sybSource2();
move_arm(OIL);
// move_arm(OIL);
// syb(PAN_LENGTH);
// emskKnife();
// fixHeigth();
// move_arm(OIL);
}
void testUpandDown()
{
ARM.step(-700);
delay(2000);
ARM.step(700);
}
void testLocations()
{
// go to source 1
move_arm(NON_KNIFE);
testUpandDown();
// go to SERVEWATER
move_arm(SERVEWATER);
testUpandDown();
// go to A2LB
move_arm(A2LB);
testUpandDown();
// go to flame 1
move_arm(WATER);
testUpandDown();
// go to OIL
move_arm(OIL);
testUpandDown();
// go to KNIFE
move_arm(KNIFE);
testUpandDown();
}
void move_arm(int location)
{
location -= Current_Location;
// go to the location via stepper Base
Base.step(location);
Current_Location += location;
delay(1000);
}
// function to get the pan
void emsk(int L)
{
Base.step(20);
delay(1000);
ARM.step(-L);
Base.step(-20);
delay(1000);
ARM.step(L);
delay(1000);
}
// function to left the pan
void syb(int L)
{
ARM.step(-L);
delay(1000);
Base.step(20);
delay(1000);
ARM.step(L);
delay(1000);
Base.step(-20);
}
void fixHeigth()
{
if (Current_Location == NON_KNIFE)
{
Base.step(40);
Current_Location += 40;
delay(500);
ARM.step(GROUND_LENGTH - NON_KNIFE_HEIGHT);
delay(500);
}
else if (Current_Location == KNIFE)
{
Base.step(-40);
Current_Location -= 40;
delay(500);
ARM.step(GROUND_LENGTH - KNIFE_HEIGHT);
delay(500);
}
}
void emskNonKnife()
{
move_arm(NON_KNIFE);
Base.step(20);
delay(1000);
ARM.step(-GROUND_LENGTH);
Base.step(-20);
delay(2000);
ARM.step(NON_KNIFE_HEIGHT);
delay(1000);
}
void emskKnife()
{
move_arm(OIL);
delay(1000);
Base.step(40);
Current_Location += 40;
delay(1000);
ARM.step(-GROUND_LENGTH);
move_arm(KNIFE);
delay(4000);
ARM.step(KNIFE_HEIGHT);
}
void a2lb(int L)
{
// go away to catch
Base.step(20);
delay(100);
// down to esmsk
ARM.step(-L);
delay(1000);
// go left
Base.step(-20);
delay(1000);
// up 45 lenght
ARM.step(120); // up
delay(2000);
Base.step(-150); // right
delay(200);
// finished then back to origin position
Base.step(150); // left
delay(200);
ARM.step(-120); // down
delay(2000);
// go away to left
Base.step(20);
delay(100);
// up
ARM.step(L);
delay(1000);
// go away to left
Base.step(-20);
delay(100);
}
// some nonsense
void nodd()
{
move_arm(3);
Base.step(20);
delay(1000);
Base.step(-20);
delay(1000);
Base.step(20);
delay(1000);
Base.step(-20);
delay(1000);
}
void sybSource1()
{
move_arm(SERVEWATER);
delay(1000);
Base.step(-60);
Current_Location -= 60;
delay(1000);
ARM.step(-(GROUND_LENGTH - NON_KNIFE_HEIGHT));
delay(1000);
move_arm(NON_KNIFE);
Base.step(10);
delay(3000);
ARM.step(-NON_KNIFE_HEIGHT);
delay(1000);
Base.step(20);
delay(1000);
ARM.step(GROUND_LENGTH);
delay(1000);
Base.step(-20);
}
void sybSource2()
{
move_arm(OIL);
delay(1000);
Base.step(40);
Current_Location += 40;
delay(1000);
ARM.step(-(GROUND_LENGTH - 170));
delay(1000);
move_arm(KNIFE);
delay(2000);
ARM.step(-170);
delay(1000);
Base.step(35);
delay(1000);
ARM.step(GROUND_LENGTH);
delay(1000);
Base.step(-35);
}