Code Along - Chapter 22
ESP32: 0-4095 to Percent
Use map() to turn a 0-4095 reading into 0 to 100.
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 22.1
0-4095 to percent
An ESP32 reading goes from 0 to 4095. The pot is half way, so reading is 2048. Use map() to turn it into 0 to 100, store it in percent, then print percent.
Sample output
50