ADC and PWM: reading a potentiometer and dimming an LED
To read an analog voltage with the microcontroller's ADC and set an LED's brightness with PWM.
Theory
The Uno's 10-bit ADC maps 0–5 V to 0–1023: count = Vin × 1023 / 5, so one step is about 4.9 mV. PWM switches a pin on and off quickly; the duty cycle (0–255 in analogWrite) sets the average voltage: Vavg = 5 × duty / 255.
Apparatus
- Arduino Uno
- 10 kΩ potentiometer
- LED and 220 Ω resistor
- Multimeter
Circuit connections
- Potentiometer outer pins to 5V and GND, wiper to A0
- D9 (PWM ~) → 220 Ω → LED → GND
Procedure
Pre-lab check
4 questions · 75% to be readyTry the readings before the lab
| Vin (V) | ADC count | PWM duty (0–255) | Average out (V) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0.5 | 102 | 25 | 0.49 |
| 1 | 205 | 51 | 1 |
| 2 | 409 | 102 | 2 |
| 2.5 | 512 | 128 | 2.51 |
| 3 | 614 | 153 | 3 |
| 4 | 818 | 204 | 4 |
| 5 | 1023 | 255 | 5 |
Precautions
- Never put more than 5 V (3.3 V on ESP32) on an analog pin.
- Use a PWM pin marked ~.
My readings
Type what you measured. It goes into your record book, and to My Garage when you are signed in.
| S. No. | Vin (V) | ADC count | PWM duty (0–255) | Average out (V) |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 |
Check my readings
Put the value you set in the first column, then compare. Real parts have tolerance.
Your lab record
Everything above is free. The print-ready write-up comes with Maker.
Printed pages leave the observation table empty for your own readings.
Viva practice
Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 4.
Quick answers for your record and viva
What is the aim of the adc and pwm: reading a potentiometer and dimming an led experiment?
To read an analog voltage with the microcontroller's ADC and set an LED's brightness with PWM.
What apparatus is needed for adc and pwm: reading a potentiometer and dimming an led?
Arduino Uno, 10 kΩ potentiometer, LED and 220 Ω resistor, Multimeter.
What is the theory behind adc and pwm: reading a potentiometer and dimming an led?
The Uno's 10-bit ADC maps 0–5 V to 0–1023: count = Vin × 1023 / 5, so one step is about 4.9 mV. PWM switches a pin on and off quickly; the duty cycle (0–255 in analogWrite) sets the average voltage: Vavg = 5 × duty / 255.
What result should I get in adc and pwm: reading a potentiometer and dimming an led?
ADC counts match Vin × 1023 / 5 within ___ counts; the LED brightness follows the knob.
What precautions should I take in adc and pwm: reading a potentiometer and dimming an led?
Never put more than 5 V (3.3 V on ESP32) on an analog pin. Use a PWM pin marked ~.
