Hi,
Im new to arduino / coding in general but already made some working codes by spying some other projects in this forum with the same funktions
but now I dont have a cloue how to solve following situation:
I have an analog input with an constant on/off frequency ( a turn indicator from a car)
while this Indicator is Blinking, I want an led on an output pin to turn on (not flashing like the input).
You need to determine a state change of indicator. Once the indicator goes off after it was on (or vice versa) - remember the system time (millis).
If, say, less than 1 second has passed since the last change, the light is on, more than that, it goes out
static unsigned long TimeLastHigh = 0;
// Turn on the LED when the blinker goes on.
if (digitalRead(InputPin) == HIGH)
{
digitalWrite(OutputPin, HIGH); // Turn on LED
TimeLastHigh = millis();
}
// Turn off the LED when the blinker has been off for 1 second.
if (millis() - TimeLastHigh >= 1000)
{
digitalWrite(OutputPin, LOW); // Turn LED off
}