How can I turn-on and turn-off a led with a single button?

I need to do this simulated in a page(www.mpanzi.net/sis_pro) with the red one that service returns a json.
the functions are these:
off:http://mpanzi.net/sis_pro/led.php?led=1&fun=a
on:the same url but &fun=b
I can do it with 2 buttons but I need only one.
I am a complete amateur on this platform, if anyone has an idea about this I would appreciate it

Hello @Jorge_Manuel_Perez_M,
Maybe I haven't correctly understood your needs, but the annexed .aia shows how to make a single button to toggle between two statuses (ON/OFF).
It does not perfom the functions that you wrote in your post, it just changes the text of a label, but the mechanism shows you how to assign two procedures to a single button.
In the two procedures called by the button you can embed whatever you really need to be done in case of ON or OFF statuses.
I hope it helps.
Regards, Ugo.

Toggle_Button.aia (2.8 KB)

@uskiara exactly what I needed, I looked for many articles on the internet but there are only examples of 2 buttons thanks for the contribution now it is clear to me. I really appreciate it man

Glad of having been of some help .
Cheers. :slight_smile:

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