I need to implement a delay in such a way that if a variable is found to be true the output is 0 for 500ms. The output counter should be reset each time the variable is zero
The idea is that if the variable has noise, for example, goes from 1 to zero randomly the output will always be zero.
It depend on what he wants. Delay is very simple but have limited functionality in the big project. So if you don't need to do few things at a time, delay is OK.
I cant really use a delay, because I need to do other things in the loop (such as read the problematic input, to make sure it sticks low). I apologize if I didn't clarify this before
I currently have this code working, but would need something that allowed more inputs without a bunch of variables for each:
long previousMillis = 0;
long interval = 300;
unsigned long currentMillis = 0;
void(loop);
{
if (no_pulse)
{
//no_pulse = 0;
currentMillis = millis();
}
if((millis() - interval) > currentMillis)
{
// Normal operation
PORTD |= _BV(PORTD7);
}
else
{
// Changing input
PORTD &= ~_BV(PORTD7);
}
}