• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Text updated with a value. How?

Q&A Forum › Text updated with a value. How?
0 Vote Up Vote Down
panglum asked 6 years ago

In the code below, what causes the text above the button to display off or on?

Specifically the line <p>GPIO 26 – State</p> .

I see that it should display “GPIO 26 – State”, but where does the off or on text come from?

<body>
<h1>ESP32 Web Server</h1>
<p>GPIO 26 - State</p>
<p><a href="/26/on"><button class="button">ON</button></a></p>
<p><a href="/26/off"><button class="button">OFF</button></a></p>
<p>GPIO 27 - State</p>
<p><a href="/27/on"><button class="button">ON</button></a></p>
<p><a href="/27/off"><button class="button button2">OFF</button></a></p>
</body>
2 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi.

That part is just HTML text. That’s just to give you an idea on how you would build a page for your web server. That doesn’t update the value.

To update the value, in the Arduino code, we should concatenate a variable that holds the state of the GPIO, as follows:

client.println("<p>GPIO 27 - State " + output27State + "</p>");

In this case, the output27State is the variable that holds the GPIO state and we’re concatenating that variable with the rest of the HTML text.

I hope this is clear.

Regards,
Sara

0 Vote Up Vote Down
panglum answered 6 years ago

Thanks, that clears it up!!

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.