Arduino UNO R4 - Potentiometer fade LED
This tutorial instructs you how to program the Arduino UNO R4 to control the brightness of an LED based on the output value of a potentiometer.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables STEM V4 IoT Starter Kit (Arduino included) | |
| 1 | × | DIYables STEM V4B IoT Starter Kit (Arduino included) | |
| 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
Learn about LED and potentiometer (pinout, functionality, programming) in the tutorials provided:
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
The diagram below shows the same connections 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. To do that, mount a Proto Screw Terminal Block Shield or a Screw Shield V2 on the Arduino UNO R4. This is how it looks with the Screw Shield V2:

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Uno R4 and other components.
How To Program
- Reads the input on the analog pin A0 (value ranges from 0 to 1023)
- Convert it to a brightness level (a number from 0 to 255)
- Sets the brightness of the LED connected to pin 3.
Arduino UNO R4 Code
Detailed Instructions
Follow these instructions step by step:
- If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
- Wire the components according to the provided diagram.
- Connect the Arduino Uno R4 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
- Copy the code and open it in Arduino IDE
- Click the Upload button in Arduino IDE to upload the code to Arduino UNO R4
- Open the Serial Monitor
- Turn the potentiometer
- Observe the LED
- Check the result on the Serial Monitor