const int GPS = 2;
const int BLOQUEO = 4;
const unsigned long ANCHO_PULSO = 1500;
//byte estadoActual;
byte estadoAnterior;
bool estadoPulso = false;
unsigned long tiempoPulso;
void setup() {
pinMode (GPS, INPUT);
pinMode (BLOQUEO, OUTPUT);
estadoAnterior = digitalRead (GPS);
}
void loop() {
byte estadoActual = digitalRead (GPS);
if (estadoActual != estadoAnterior) {
if (estadoActual == HIGH) {
tiempoPulso = millis();
estadoPulso = true;
digitalWrite (BLOQUEO, HIGH);
}
delay(10);
estadoAnterior = estadoActual;
}
if (estadoPulso == true) {
if (millis() - tiempoPulso > ANCHO_PULSO) {
digitalWrite (BLOQUEO, LOW);
estadoPulso = false;
}
}
}