/
toss_juggler.ino
59 lines (51 loc) · 1.25 KB
/
toss_juggler.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
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::DRIVER, 9, 8);
AccelStepper stepper2(AccelStepper::DRIVER, 4, 3);
int start = 0;
int side = 0;
int max_speed = 5200;
int max_acceleration = 11000;
int starting_rotation = 200;
int stepover = 280;
int step_distance = 800;
void setup()
{
//sdfsd
stepper1.setMaxSpeed(max_speed);
stepper2.setMaxSpeed(max_speed);
stepper1.setAcceleration(1234);
stepper2.setAcceleration(1234);
stepper1.moveTo(600);
stepper2.moveTo(-200);
}
void loop()
{
if (start == 0) {
while (abs(stepper1.distanceToGo()) != 0) {
stepper1.run();
}
while (abs(stepper2.distanceToGo()) != 0) {
stepper2.run();
}
start = 1;
stepper1.setAcceleration(max_acceleration);
stepper2.setAcceleration(max_acceleration);
delay(500);
}
if (abs(stepper1.distanceToGo()) == 0
and abs(stepper2.distanceToGo()) < stepover
and side == 0) {
stepper1.moveTo(step_distance + stepper1.currentPosition());
side = 1;
}
if (abs(stepper2.distanceToGo()) == 0
and abs(stepper1.distanceToGo()) < stepover
and side == 1) {
stepper2.moveTo(step_distance + stepper2.currentPosition());
side = 0;
}
if (start == 1) {
stepper2.run();
stepper1.run();
}
}