-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.ino
45 lines (37 loc) · 876 Bytes
/
commands.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
void moveTo(int speed, int accel, int position) {
stepper.setMaxSpeed(speed);
stepper.setAcceleration(accel);
stepper.moveTo(position);
while (stepper.isRunning()) {
stepper.run();
}
}
bool zeroAxis(int speed, int accel, int stroke) {
stepper.setMaxSpeed(speed);
stepper.setAcceleration(accel);
stepper.move(stroke);
while (stepper.isRunning()) {
stepper.run();
if ( !digitalRead(NOT_LIMIT) ) {
break;
}
}
stepper.disableOutputs ();
stepper.stop ();
stepper.setCurrentPosition(0);
return (bool)!digitalRead(NOT_LIMIT);
}
void pushDozer(int on, int off, int cycleDuration, bool isLastPush) {
servo.write(on);
delay(cycleDuration);
servo.write(off);
if (isLastPush) {
delay(SERVO_DELAY);
} else {
delay(cycleDuration);
}
}
void setDozerPosition(int pos) {
servo.write(pos);
delay(SERVO_DELAY);
}