-
Notifications
You must be signed in to change notification settings - Fork 0
/
Coordinar_motors.ino
56 lines (44 loc) · 1.24 KB
/
Coordinar_motors.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
#include <Stepper.h>
#define motor1StepPin 6
#define motor1DirPin 7
#define motor2StepPin 8
#define motor2DirPin 9
#define stepsPerRevolution 6400
const float PaperWidth = 0.0001;
const float InitialHeight = 0.041; //(r)
const float ReelHeight = 0.03;
int stepsDone = 0;
Stepper motor1(stepsPerRevolution, motor1StepPin, motor1DirPin);
Stepper motor2(stepsPerRevolution, motor2StepPin, motor2DirPin);
void setup() {
// set the speed:
motor1.setSpeed(60);
motor2.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
//moveSteppers(3200);
}
void moveSteppers(int steps){
for (int i = 0; i < steps; i++){
motor1.step(1);
motor2.step(1);
}
}
void rotateCoordinated(int steps){
for (int i = 0; i < steps; i += 15){
int a = 15*((InitialHeight + ReelHeight - PaperWidth*(stepsDone/(6400*4)))/(InitialHeight + PaperWidth*(stepsDone/(6400*4))));
motor1.step(10);
motor2.step(a);
stepsDone += 15;
/* Serial.print("stepsDone: ");
Serial.print(stepsDone);
Serial.print(", 0: ");
Serial.print(a);
Serial.print(", i: ");
Serial.print(i);
Serial.println();*/
}
}
void loop() {
rotateCoordinated(5000);
}