1#include <AFMotor.h>
2AF_Stepper motor2(200, 2);
3AF_Stepper motor1(200, 1);
4int step360 = 0;
5int speed2 = 2;
6int speed5 = 50;
7int speed10 = 10;
8int speed15 = 15;
9int speed20 = 20;
10int i = 0;
11void setup() {
12 Serial.begin(9600);
13
14 motor1.setSpeed(100);
15 motor2.setSpeed(100);
16}
17
18void loop() {
19 Serial.println("pattern1");
20 pattern1();
21 Serial.println("pattern2");
22 pattern2();
23 Serial.println("pattern3");
24 pattern3();
25 Serial.println("pattern4");
26 pattern4();
27 Serial.println("pattern5");
28 pattern5();
29
30
31
32}
33
34void pattern1(){
35 motor1.setSpeed(speed5);
36 motor2.setSpeed(speed5);
37 for (int i = 0; i <= 200; ) {
38 if (step360 == 200){
39 motor2.step(2, FORWARD, INTERLEAVE);
40 step360= 0;
41 i++;
42 }
43 else{
44 motor1.step(2, FORWARD, INTERLEAVE);
45 motor2.step(1, FORWARD, INTERLEAVE);
46 step360 = step360+1;
47 }
48 }
49}
50
51void pattern2(){
52 i = 0;
53 motor1.setSpeed(speed5);
54 motor2.setSpeed(speed5);
55 for (int i = 0; i <= 100; ) {
56 if (step360 == 200){
57 motor2.step(2, FORWARD, INTERLEAVE);
58 step360= 0;
59 i++;
60
61 }
62 else{
63 motor1.step(4, FORWARD, INTERLEAVE);
64 motor2.step(1, FORWARD, INTERLEAVE);
65 step360 = step360+1;
66 }
67 }
68}
69
70void pattern3(){
71 i = 0;
72 motor1.setSpeed(speed5);
73 motor2.setSpeed(speed5);
74 for (int i = 0; i <= 100;) {
75 if (step360 == 200){
76 motor2.step(2, FORWARD, INTERLEAVE);
77 step360= 0;
78 i++;
79
80 }
81 else{
82 motor1.step(3, FORWARD, INTERLEAVE);
83 motor2.step(2, FORWARD, INTERLEAVE);
84 step360 = step360+2;
85 }
86 }
87}
88void pattern4(){
89 i = 0;
90 motor1.setSpeed(speed5);
91 motor2.setSpeed(speed10);
92 for (int i = 0; i <= 100;) {
93 if (step360 == 200){
94 motor2.step(2, FORWARD, INTERLEAVE);
95 step360= 0;
96 i++;
97
98 }
99 else{
100 motor1.step(3, FORWARD, INTERLEAVE);
101 motor2.step(1, FORWARD, INTERLEAVE);
102 step360 = step360+1;
103 }
104 }
105}
106void pattern5(){
107 i = 0;
108 motor1.setSpeed(speed2);
109 motor2.setSpeed(speed5);
110 for (int i = 0; i <= 100;) {
111
112 if (step360 == 200){
113 motor2.step(2,FORWARD, INTERLEAVE);
114 step360= 0;
115 i++;
116
117 }
118 else{
119 motor1.step(10, FORWARD, INTERLEAVE);
120 motor2.step(1, FORWARD, INTERLEAVE);
121 step360 = step360+1;
122
123 }
124 }
125}
germank
8 months ago
hola, como estas, como, puedo contactarme con vos?