
Problema para procesar comandos
Publicado por Akame (3 intervenciones) el 26/05/2023 11:14:42
Tengo una función para procesar comandos recibidos desde una interfaz de usuario y con eso mover un motor paso a paso y tal y como está ahí los comandos x, y, l, t los procesa bien porque si que hace el movimiento pero los demás no. Estaría muy agradecida si alguien me pudiese ayudar. Un saludo!
PD: dejo adjuntado el código completo por si es necesario consultar algo más del código
PD: dejo adjuntado el código completo por si es necesario consultar algo más del código
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
void processCommand() {
if (inputString.startsWith("x")) {
distX = inputString.substring(1);
Serial.println("DistX recibida");
}
else if (inputString.startsWith("y")) {
distY = inputString.substring(1);
Serial.println("DistY recibida");
}
else if (inputString.startsWith("l")) {
caract = inputString.substring(1);
Serial.println("Caract recibida");
}
else if (inputString.startsWith("t")) {
t_1 = inputString.substring(1);
Serial.println("t_1 recibida");
}
else if (inputString.equals("d")) {
digitalWrite(dirPinH, HIGH);
giroMotor = 3;
Serial.println("Derecha");
}
else if (inputString.equals("D")) {
digitalWrite(dirPinH, HIGH);
giroMotor = 1;
}
else if (inputString.equals("a")) {
digitalWrite(dirPinH, LOW);
giroMotor = 4;
Serial.println("Izquierda");
}
else if (inputString.equals("A")) {
digitalWrite(dirPinH, LOW);
giroMotor = 2;
}
else if (inputString.equals("C")) {
giroMotor = 0;
delay(50);
Serial.println("Paro");
}
else if (inputString.equals("w")) {
digitalWrite(dirPinV, HIGH);
giroMotor = 5;
Serial.println("Arriba");
}
else if (inputString.equals("W")) {
digitalWrite(dirPinV, HIGH);
giroMotor = 6;
}
else if (inputString.equals("s")) {
digitalWrite(dirPinV, LOW);
giroMotor = 7;
Serial.println("Abajo");
}
else if (inputString.equals("S")) {
digitalWrite(dirPinV, LOW);
giroMotor = 8;
}
}
- final-2.zip(1,3 KB)
Valora esta pregunta


0