-
Notifications
You must be signed in to change notification settings - Fork 1
/
Movimiento_Angular.ino
92 lines (81 loc) · 2 KB
/
Movimiento_Angular.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
void movimientoAngular(int x){
if(variablePasada != x){
digitalWrite(pm1_a,LOW);
digitalWrite(pm2_a,LOW);
digitalWrite(pm3_a,LOW);
digitalWrite(pm1_r,LOW);
digitalWrite(pm2_r,LOW);
digitalWrite(pm3_r,LOW);
v1=200;
v2=200;
v3=200;
analogWrite(pm1v, v1);
analogWrite(pm2v, v2);
analogWrite(pm3v, v3);
switch(x){
case 1: //Adelante
digitalWrite(pm3_r,HIGH);
digitalWrite(pm1_a,HIGH);
break;
case 2: //Adelante a la izquierda
digitalWrite(pm2_a,HIGH);
digitalWrite(pm3_r,HIGH);
break;
case 3: //A la izquierda
digitalWrite(pm1_a,LOW);
digitalWrite(pm2_a,HIGH);
digitalWrite(pm3_a,LOW);
digitalWrite(pm1_r,HIGH);
digitalWrite(pm2_r,LOW);
digitalWrite(pm3_r,HIGH);
break;
case 4: //Atras a la izquierda
digitalWrite(pm2_a,HIGH);
digitalWrite(pm1_r,HIGH);
break;
case 5: //Atras
digitalWrite(pm1_r,HIGH);
digitalWrite(pm3_a,HIGH);
break;
case 6: //Atras a la derecha
digitalWrite(pm3_a,HIGH);
digitalWrite(pm2_r,HIGH);
break;
case 7: //Derecha
digitalWrite(pm1_a,HIGH);
digitalWrite(pm2_a,LOW);
digitalWrite(pm3_a,HIGH);
digitalWrite(pm1_r,LOW);
digitalWrite(pm2_r,HIGH);
digitalWrite(pm3_r,LOW);
break;
case 8: //Adelante a la derecha
digitalWrite(pm1_a,HIGH);
digitalWrite(pm2_r,HIGH);
break;
case 98: //Girar a la izquierda
v1=200;
v2=200;
v3=200;
analogWrite(pm1v, v1);
analogWrite(pm2v, v2);
analogWrite(pm3v, v3);
digitalWrite(pm1_r,HIGH);
digitalWrite(pm2_r,HIGH);
digitalWrite(pm3_r,HIGH);
break;
case 99: //Girar a la derecha
v1=200;
v2=200;
v3=200;
analogWrite(pm1v, v1);
analogWrite(pm2v, v2);
analogWrite(pm3v, v3);
digitalWrite(pm1_a,HIGH);
digitalWrite(pm2_a,HIGH);
digitalWrite(pm3_a,HIGH);
break;
}
variablePasada = x;
}
}