Need Help how to implement funktion

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 :smiley:

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).

if anyone can help me would be very nice :slight_smile:

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

You can aldo use a timer.

if (blink==HIGH) {
    reset timer;
}
if (!timer overdue) {
    put on Led;
}

The timer should be set for a duration just a bit longer than your blinking interval.

  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
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.