Presionar PM1
Publicado por Julia (1 intervención) el 08/07/2021 19:54:20
Al presionar el botón PM1, el led D1 debe apagarse y el motor 2 debe subir por 2
segundos y parar.
• Después de 1 segundo, se debe encender automáticamente el Motor de
Desplazamiento hacia la izquierda también por 2 segundos y parar.
• Después de 1 segundo, se debe encender automáticamente el Motor 1, el cual debe
bajar también por 2 segundos y parar
Como hago en este caso, hasta ahora voy así, tiene que estar el led aqua prendido y al presionar el boton PM1 debe apagarse;pero eso no sucede, cual es el problema ahi aparte, también debe iniciar todo el motor al presionar PM1, y eso tampoco sucede, necesito su ayuda por favor.
segundos y parar.
• Después de 1 segundo, se debe encender automáticamente el Motor de
Desplazamiento hacia la izquierda también por 2 segundos y parar.
• Después de 1 segundo, se debe encender automáticamente el Motor 1, el cual debe
bajar también por 2 segundos y parar
Como hago en este caso, hasta ahora voy así, tiene que estar el led aqua prendido y al presionar el boton PM1 debe apagarse;pero eso no sucede, cual es el problema ahi aparte, también debe iniciar todo el motor al presionar PM1, y eso tampoco sucede, necesito su ayuda por favor.
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
int paq1=0;
int LEDAQUA=9;
int LEDAMARILLO=8;
int MAB2=7;
int MAR2=6;
int MDR=5;
int MIZ=4;
int MAR1=3;
int MAB1=2;
int paquete;
int PM1=12;
void setup() {
pinMode(13,INPUT);
pinMode(12,INPUT);
pinMode(11,INPUT);
pinMode(10,INPUT);
pinMode(9,INPUT);
pinMode(8,INPUT);
pinMode(7,INPUT);
pinMode(6,INPUT);
pinMode(5,INPUT);
pinMode(4,INPUT);
pinMode(3,INPUT);
pinMode(2,INPUT);
Serial.begin(9600);
}
void subirMotor2()
{
digitalWrite(MAR1,LOW);
digitalWrite(MAB1,LOW);
digitalWrite(MAR2,HIGH);
digitalWrite(MAB2,LOW);
digitalWrite(LEDAQUA,LOW);
delay(2000);
}
void pararMotor2()
{
digitalWrite(MAR1,LOW);
digitalWrite(MAB1,LOW);
digitalWrite(MAR2,LOW);
digitalWrite(MAB2,LOW);
delay(1000);
}
void desplazamientoizquierdaMotor()
{
digitalWrite(MIZ,HIGH);
digitalWrite(MAB1,LOW);
digitalWrite(MAR2,LOW);
digitalWrite(MAB2,LOW);
delay(2000);
}
void pararMotor()
{
digitalWrite(MIZ,LOW);
digitalWrite(MAB1,LOW);
digitalWrite(MAR2,LOW);
digitalWrite(MAB2,LOW);
delay(1000);
}
void bajarMotor1()
{
digitalWrite(MAB1,HIGH);
digitalWrite(MAR1,LOW);
digitalWrite(MAR2,LOW);
digitalWrite(MAB2,LOW);
delay(2000);
}
void detenerMotor1()
{
digitalWrite(MAB1,LOW);
digitalWrite(MAR1,LOW);
digitalWrite(MAR2,LOW);
digitalWrite(MAB2,LOW);
delay(1000);
}
int leerPM1;
int leerLEDD1;
int leerPM2;
void loop() {
leerPM1 = digitalRead(PM1);
Serial.println("Presione PM1 para inicio de secuencia");
while(leerPM1 == 0)
{
leerPM1 = digitalRead(PM1);
digitalWrite(LEDAQUA,HIGH);
}
subirMotor2();
delay(2000);
while(leerPM1 == 0)
{
leerPM1 = digitalRead(PM1);
pararMotor2();
delay(1000);
desplazamientoizquierdaMotor();
delay(2000);
pararMotor();
delay(1000);
bajarMotor1();
delay(2000);
detenerMotor1();
delay(1000);
}
Serial.println("Saliste del motor");
delay(5000);
}
Valora esta pregunta


0