ElectronLab Project Lab
Arduino Core ADC & PWM Voltage Dividers

Analog LED Brightness Control with Potentiometer & PWM Dimming

Master 10-bit analog-to-digital conversion (ADC), variable voltage dividers, and 8-bit pulse-width modulation (PWM) to create smooth, flicker-free LED dimmer controls.

Reading Time 5 Minutes
Difficulty Level Beginner
Hardware Platform Arduino Uno

1. Aim of the Project

Project Objective

The goal is to read a variable 0-5V analog voltage generated by turning a 10k rotary potentiometer using the Arduino 10-bit ADC (values 0-1023), scale this number mathematically using map() into an 8-bit duty cycle (0-255), and modulate an LED's perceived brightness smoothly via PWM.

2. Interactive 3D Assembly & Circuit Wiring Model

Rotate the 3D model 360 degrees, zoom in/out, disassemble/explode parts to inspect individual hardware layers, toggle realistic circuit wires, and click any component to inspect its engineering specifications.

3D Hardware Simulation & Assembly Lab
Left Click + Drag: Rotate Orbit (360°)
Right Click + Drag: Pan Scene
Scroll: Zoom In / Out
Click Component: Inspect Hardware Details
Hovered Component

3. Laboratory Video Masterclass Tutorial

Step-by-step video walkthrough covering breadboard circuit assembly, wiring verification, and testing. Enrolled students and instructors can access video streaming below.

2. Learning Outcomes

PWM Duty Cycle Mechanics

Learn how microcontrollers simulate analog voltages by switching digital pins ON and OFF at 490 Hz / 980 Hz.

ADC Quantization

Understand how 5V is discretized across 1024 distinct integer steps (4.88 mV per count).

3. Required Components

Component Name Quantity Specification Interface
Arduino Uno 1 ATmega328P Board USB / 5V
10k Rotary Potentiometer 1 Linear variable resistor Analog Pin A0
5mm LED (Any Color) 1 Diffused light emitting diode PWM Pin D9
220 Ohm Resistor 1 Current limiter for LED Passive

4. Circuit Connections

Component Pin Arduino Pin Description
Potentiometer Pin 1 5V Rail Upper reference voltage
Potentiometer Pin 2 (Wiper) Analog Pin A0 Variable voltage output
Potentiometer Pin 3 GND Rail Lower ground reference
LED Anode (+) via 220R Digital Pin D9 (PWM) PWM Duty cycle drive output
LED Cathode (-) GND Rail Common Ground

5. Complete Arduino Source Code

potentiometer_pwm_dimmer.ino
/*
 * Project: Analog LED Brightness Control with Potentiometer
 * Author: ElectronLab STEM Curriculum
 */

const int POT_PIN = A0;  // Potentiometer wiper pin
const int LED_PIN = 9;   // PWM Output pin (marked with ~)

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  // Read 10-bit analog value (0 to 1023)
  int potValue = analogRead(POT_PIN);

  // Map 10-bit input to 8-bit PWM output (0 to 255)
  int pwmValue = map(potValue, 0, 1023, 0, 255);

  // Write PWM signal to LED
  analogWrite(LED_PIN, pwmValue);

  // Print telemetry to Serial Plotter / Monitor
  float voltage = (float)potValue * (5.0 / 1023.0);
  Serial.print("Raw ADC: ");
  Serial.print(potValue);
  Serial.print(" | Voltage: ");
  Serial.print(voltage, 2);
  Serial.print(" V | PWM Duty: ");
  Serial.println(pwmValue);

  delay(20); // Smooth update rate
}

6. Working Principle

Turning the potentiometer dial moves an internal wiper contact across a resistive carbon track, forming an adjustable voltage divider. The Arduino's Successive Approximation ADC converts this analog voltage into a digital number. By altering the high-to-low ratio of 490 Hz square wave pulses (Duty Cycle), the human eye perceives changing optical brightness due to the persistence of vision.

7. Troubleshooting Guide

LED Only Turns Fully ON or Fully OFF

Ensure the LED is connected to a hardware PWM pin marked with a tilde (~) on the Arduino board (Pins 3, 5, 6, 9, 10, or 11).