I’m building a small project on Arduino web serwer with some buttons.
When I’m clicking on “ON”, the web page changes ftom eg. 192.168.0.50 to 192.168.0.50/LED_ON
then the Arduino code lights the LED. - this is good.
and back when I click on “OFF” buton the page redirects to 192.168.0.50/LED_OFF and the Arduino code lights the LED off. - thats;s good.
I want to add some status on the web page (to know if the LED is ON or OFF). I’m doing this by adding a variable and setting it to 0 or 1 after turning the led on or off.
My problem is to immediately update it to the web page.
I know I can do this by HTML META DATA, but sensible value is 3 or 5 sec. but cannot wait ant want to have the information ASPA just after clicking.
I found a resolution saying that can do this by sucha a code:
client.println("<a href="/LIVING_LED_ON"><button onclick=“myFunction()”>On ");
The problem is that this coce refreshes the main page (192.168.0.50) and don’t redirect to 192.168.0.50/LIVING_LED_ON and in effect the led doesn’t lights.
Is there a way to first change the page to the subpage /LIVING_LED_ON so the LED lights and then reload a page so the status chanes immediately,
is there another way to pass a information from the web server to rest of Arduino code that buton was clicked - not by subpages like /LIVING_LED_ON or /LIVING_LED_OFF, then I could stay always on main page and just reloading it,
can I pass some variable from the web server after buton click to the rest code controlling Arduino pins that I can use reloading script.
Just please help you are my last chanse…
The code in new post…