
LED Brightness with a Potentiometer
Beginner20 minSet an LED's brightness by turning a potentiometer's knob: with the knob at one end the LED is off, and it gets brighter as you turn towards the other end. The value read and the brightness given to the LED are also written to the Serial Monitor. It teaches reading an analog input with analogRead, turning one range into another with map, and using PWM with analogWrite. No extra library needed.

What you need
1 × Arduino Uno R3
1 × Breadboard 830 Points (MB-102)
1 × 10K Potentiometer
1 × LED - Red (5mm)
1 × Resistor 220 Ω (1/4W)
6 × Jumper Wire - Male/Male
Wiring steps
- 1
Connect the power rails (5V and GND)

Plug a black jumper wire into one of the GND pins on the Arduino's power header and connect its other end to the breadboard's bottom blue (−) rail. Plug a red jumper wire into the 5V pin on the same header and connect its other end to the bottom red (+) rail. The potentiometer is powered from these two rails, and the LED's resistor goes into the (−) rail.
- Arduino GND → the bottom blue (−) rail (black wire)
- Arduino 5V → the bottom red (+) rail (red wire)
- 2
Add the LED and its resistor

Plug the red LED's long leg (+) into column 11 in the bottom half of the breadboard and its short leg (−) into column 10. Put one end of the 220 Ω resistor in column 10 and the other end in the bottom (−) rail. Then connect the Arduino's pin ~9 to column 11 with a blue jumper wire (LED_PIN 9). The ~ in front of a pin number means that pin can do PWM; to set the brightness, the LED must be on such a pin (3, 5, 6, 9, 10 and 11 on the Uno).
- red LED long leg (+) → column 11, bottom half
- red LED short leg (−) → column 10, bottom half
- 220 Ω resistor (leg 1) → column 10, bottom half
- 220 Ω resistor (leg 2) → the bottom blue (−) rail
- Arduino pin 9 → column 11, bottom half (blue wire)
- 3
Add and wire the potentiometer

Plug the potentiometer's three legs into columns 4, 5 and 6 in the bottom half. Connect column 4 to the bottom (+) rail with a short red wire and column 6 to the bottom (−) rail with a short black wire. Then connect the Arduino's A0 pin to the middle leg's column, column 5, with a yellow jumper wire (POT_PIN A0). The two outer legs give the potentiometer 0 V and 5 V; as you turn the knob, the middle leg gives a voltage between the two, which the Arduino reads as a number from 0 to 1023.
- potentiometer left leg → column 4, bottom half
- potentiometer middle leg → column 5, bottom half
- potentiometer right leg → column 6, bottom half
- column 4, bottom half → the bottom red (+) rail (red wire)
- column 6, bottom half → the bottom blue (−) rail (black wire)
- Arduino A0 → column 5, bottom half (yellow wire)
Arduino sketch
Download the sketch (.ino)Try it on Wokwi
// Middle leg of the potentiometer: A0
const int POT_PIN = A0;
// LED on ~9: analogWrite needs a PWM pin
const int LED_PIN = 9;
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// From 0 (one end) to 1023 (the other)
int potValue = analogRead(POT_PIN);
// Turn 0–1023 into PWM's 0–255
int brightness = map(potValue, 0, 1023, 0, 255);
analogWrite(LED_PIN, brightness);
Serial.print("Potentiometer: ");
Serial.print(potValue);
Serial.print(" Brightness: ");
Serial.println(brightness);
delay(200);
}
What the Serial Monitor shows
Potentiometer: 0 Brightness: 0 Potentiometer: 256 Brightness: 63 Potentiometer: 512 Brightness: 127 Potentiometer: 768 Brightness: 191 Potentiometer: 1023 Brightness: 255
What you will see
With the knob at one end the LED is off; as you turn it towards the other end it slowly gets brighter, and at the very end it lights at full brightness. In the Serial Monitor the potentiometer value (0 to 1023) and the brightness (0 to 255) change with the knob. If the value never changes, check that the yellow wire is in the middle leg's column (5). If the value changes but the LED stays the same or never lights, check that the LED's wire is on pin ~9 and its long leg is in column 11.
Similar projects
Servo with a PotentiometerBeginner25 minAs you turn a potentiometer's knob, an SG90 servo motor turns with it: one end of the knob is 0°, the other 180°. The angle the servo stops at is also written to the Serial Monitor. It teaches adding a library (Servo) to a project, turning a value read with analogRead into an angle with map, and sending a motor to the angle you want with servo.write. The Servo library comes with the Arduino IDE, so there is nothing to install.Open project
Arduino-Free Dark-Activated LampBeginner25 minA night light with no Arduino and no code, built from just a 9V battery, a BC547 transistor, an LDR and a potentiometer: when it gets dark the LED lights by itself, and it goes out when the light comes back. With the potentiometer you set how dark it must be. It teaches three cornerstones of basic electronics: the voltage divider (the potentiometer and the LDR), the transistor as a switch that turns a large current on and off with a small base current, and limiting an LED's current with a resistor. You see how these parts, used in Arduino projects all the time, work without one.Open project
Digital VoltmeterBeginner20 minA voltmeter that measures between 0 and 5 V with the Arduino's analog input: as you turn the potentiometer, the voltage on pin A0 changes; the 16x2 LCD shows it in volts on its top row (e.g. 3.27 V) and as a bar filling from the left on its bottom row. It teaches how an analog reading (0–1023) turns into volts, how averaging readings steadies them, and how to teach the LCD characters of your own to draw a bar. Install "LiquidCrystal I2C" from the Library Manager.Open project
In the app, tick off every wire, match the parts to your inventory and pick up where you left off.
