Code Along - Chapter 23
ESP32: A Web Page as Text
Build a web page as a String with page +=, then turn a slider value into a brightness.
ESP32 code on the virtual board
The virtual board is an Uno, not an ESP32, so there is no Wi-Fi here. You practise the code around it. A pot reading is a pretend number in a variable, like int reading = 2048;. The LED on GPIO 2 works the same; the test list calls it pin D2.
Exercise 23.1
Build a web page as text
A web server sends its page as one long String. page += adds text to the end. Add <p>LED is ON</p> when ledOn is true, or <p>LED is OFF</p> when it is false.
Sample output
<h1>ESP32 lamp</h1><p>LED is ON</p>
Exercise 23.2
A slider value from the browser
A web page slider sends its value as text, like "300". Turn it into a number with value.toInt(), keep it between 0 and 255 with constrain(), then print it.
Sample output
255