
Interactive circuit guide
Run the simulation, follow the build steps one by one and try it in our real app.
Stopped
Step-by-step build
What it does
The two outer legs of a 10 kiloohm potentiometer go to the 5 V rail and to ground, while the middle leg goes to an analog input. Turning the knob changes the voltage at the middle leg between 0 V and 5 V, and the board converts that voltage into a number. The sketch maps the number to a PWM output, which switches the pin on and off very quickly so the average voltage changes. The LED is still driven through a 220 ohm series resistor. This circuit shows the conversion from analog input to digital output and the idea of controlled adjustment.
Parts you need
Use the following parts to build this circuit:
- Arduino Uno × 1 — Reads the analog value and produces a PWM output.
- 10 kΩ potentiometer × 1 — Acts as a voltage divider to produce the adjustment voltage.
- 220 Ω resistor × 1 — Limits the LED current.
- Red LED × 1 — Output device whose brightness is adjusted.
- Ground connection × 1 — Common reference for the divider and the LED.
Build it step by step
- Place the board and put the potentiometer in the upper row.A potentiometer has three legs: two ends and one middle leg.
- Connect one end of the potentiometer to 5 V and the other to ground.This places a steady 5 V across the two end legs.
- Connect the middle leg to an analog input pin.The value read at this pin changes as you turn the knob.
- Connect a PWM output pin through a 220 Ω resistor and the LED to ground.The LED anode goes to the resistor, the cathode to ground.
- Connect the board GND pin to the common ground rail.Power and signals must share one reference.
- Upload the sketch and turn the knob to watch the brightness change.At the lowest value the LED is off; at the highest it is brightest.
How it works
The potentiometer divides the 5 V across its end legs according to the position of the middle leg. That middle leg produces an analog voltage that varies continuously between 0 V and 5 V, and the analog-to-digital converter turns it into a number. The sketch maps that number to the duty cycle of a PWM output. A PWM signal is a square wave that switches on and off at a fixed frequency, so a longer on-time sends more average current through the LED and it appears brighter. The eye cannot resolve the fast switching, so the change looks smooth. The 220 ohm resistor keeps the LED current in a safe range even at the brightest setting.
What you learn
- Relate analog input reading to PWM output generation.
- Explain the use of a potentiometer as a voltage divider.
- Understand the role of pulse width modulation in brightness control.
- Interpret the conversion between an analog and a digital signal.
Tips
- If the middle leg is not connected, the reading will not change; check the wiring.
- If the LED flickers, try raising the PWM frequency.
- Increasing LED brightness without a resistor can damage the component.
Try it yourself
- Turn the knob fully left and fully right and compare the brightness.
- Observe the relationship between the analog reading and the PWM duty cycle.
- Change the resistor value and interpret the current limit at the brightest setting.
Expected result: As the potentiometer turns, the LED dims gradually and then becomes bright again.
Get the parts
If you want to build this project for real, you can get the parts from hobidevre.com.
Frequently asked questions
What is this circuit for?
The two outer legs of a 10 kiloohm potentiometer go to the 5 V rail and to ground, while the middle leg goes to an analog input. Turning the knob changes the voltage at the middle leg between 0 V and 5 V, and the board converts that voltage into a number. The sketch maps the number to a PWM output, which switches the pin on and off very quickly so the average voltage changes. The LED is still driven through a 220 ohm series resistor. This circuit shows the conversion from analog input to digital output and the idea of controlled adjustment.
How does it work?
The potentiometer divides the 5 V across its end legs according to the position of the middle leg. That middle leg produces an analog voltage that varies continuously between 0 V and 5 V, and the analog-to-digital converter turns it into a number. The sketch maps that number to the duty cycle of a PWM output. A PWM signal is a square wave that switches on and off at a fixed frequency, so a longer on-time sends more average current through the LED and it appears brighter. The eye cannot resolve the fast switching, so the change looks smooth. The 220 ohm resistor keeps the LED current in a safe range even at the brightest setting.
What should I see at the end?
As the potentiometer turns, the LED dims gradually and then becomes bright again.