Lab / Microcontrollers and sensors

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.

Microcontrollers and sensorsVirtual readings4 viva questions
I = 13 mA

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 ready
1What is the resolution of a 10-bit ADC at 5 V?
2What is duty cycle?
3Is PWM true analog output?
4Name the ADC type in most microcontrollers.

Try the readings before the lab

Calculated, not measured. In the lab, write down your own readings.
02765528291.1k01.252.53.755Vin (V)ADC count
Vin (V)ADC countPWM duty (0–255)Average out (V)
0000
0.5102250.49
1205511
24091022
2.55121282.51
36141533
48182044
510232555

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 countPWM 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.

Open my record book

Your lab record

Result formatADC counts match Vin × 1023 / 5 within ___ counts; the LED brightness follows the knob.

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.

1. What is the resolution of a 10-bit ADC at 5 V?
2. What is duty cycle?
3. Is PWM true analog output?
4. Name the ADC type in most microcontrollers.

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 ~.

ADC and PWM: reading a potentiometer and dimming an LED