Arduino Nano ESP32 - Potentiometer LED
This tutorial instructs you how to use Arduino Nano ESP32 with the potentiometer to change the brightness of LED.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: Use the LED Module for easier wiring. It includes an integrated resistor.
Overview of LED and Potentiometer
We have specific tutorials about LED and potentiometer. Each tutorial contains detailed information and step-by-step instructions about hardware pinout, working principle, wiring connection to ESP32, Arduino Nano ESP32 code... Learn more about them at the following links:
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Here is the same wiring without a breadboard:

This image is created using Fritzing. Click to enlarge image
Jumper wires are good for a quick test, but not for a final build. Simply plug the Arduino Nano ESP32 into a Screw Terminal Expansion Board for Arduino Nano. See the diagram below for the screw terminal version.

This image is created using Fritzing. Click to enlarge image
How To Program
- Reads the input on analog pin (value between 0 and 4095)
- Scales it to brightness (value between 0 and 255)
- Sets the brightness LED
Arduino Nano ESP32 Code
Detailed Instructions
- If this is the first time you use Arduino Nano ESP32, see how to setup environment for Arduino Nano ESP32 on Arduino IDE.
- Copy the above code and paste it to Arduino IDE.
- Compile and upload code to Arduino Nano ESP32 board by clicking Upload button on Arduino IDE
- Open Serial Monitor on Arduino IDE

- Rotate the potentiometer
- See the LED fading
- See the result on Serial Monitor. It looks like the below: