I’d use a timer to call a function. The timer is because you want the LED widget to blink, and the frequency will be dictated by the timer.
You’ll need a global variable to track the state of the LED widget, so you can flip it.
You’ll also need a global variable to check the state of the relay, and only do the flipping if the relay is on.
The pseudocode for the timed function would be something like this…
As I said to you in one of your other topics, you should use virtual pins for your app widgets, not digital pins. It makes problems like this much simpler to solve, and is a much more reliable approach.
It also makes code much more portable between different types of boards.
If you insist on using digital pins then take the pseudo code I provided earlier and change the line that says:
to one which digitalReads the state of your relay pin and evaluates to true if your relay is activated.