Hi, I remember you helped me doing a project about a year ago but i was wondering if I could ask you semething else..
I'm trying to make like a cancelation for a input with millis
so
if input 1 is on for less than x time, output 1 is off
if input 1 is on for more than x time, output 1 is on but need to stay on even if input 1 goes off after the timer has reach the right time.
if input 2 is on for more than X time, output 1 goes off
The 2 inputs never going to be on at the same time sinse they are connected to a relay.
The following is a simple way to check if a button is pressed continuously for a certain length of time
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) { // assumes LOW when pressed and HIGH when not-pressed
lastTimeButtonWasHigh = millis();
}
if (millis() - lastTimeButtonWasHigh >= requiredTime) {
// input has been LOW throughout the required time
// do whatever needs to be done
}
}
If you need to ensure that the button has NOT been pressed during that time you will obviously need to invert the logic.