You need a coded latch.
byte latch = 0;
if(digitalRead(sensorPin) == HIGH) {
~latch; // latch = !latch; //Alternative
latch ? (/* IF stuff here /) : (/ ELSE here */);
}
You need a coded latch.
byte latch = 0;
if(digitalRead(sensorPin) == HIGH) {
~latch; // latch = !latch; //Alternative
latch ? (/* IF stuff here /) : (/ ELSE here */);
}