I want blink Led widget on app when output is on. For exemple :
D4 ( wich’s driving relais ) have to blink led widget when is high.
I think i’ve just to program D4 to virtual pin but i don’t know how…
Same for current sensor.
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…
You’ll also want to turn the LED widget off and set LED_state to 0 when you turn your relay off, but this would be done in the function where you relay on/off via a virtual pin…
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.