Potentiometers are an essential component in many analog and digital circuits. By varying voltage levels, these devices can indicate user inputs to a microcontroller via an analog-to-digital converter. We can also use them to control voltage more directly in audio or other applications, or as a variation known as a rheostat, where resistance to current flow is varied directly.
It’s sometimes possible to emulate this type of functionality in the digital world by using pulse-width modulation (PWM), where an output rapidly turns on and off to simulate an analog signal. To truly modify voltage levels, however, we’ll need another solution. For this purpose, you can implement a digital potentiometer like the MCP41XXX/42XXX from Microchip.
How Does a Digital Potentiometer Work?
Digital potentiometers are available in three variations:
1. 10kΩ
2. 50 kΩ
3. 100kΩ
Each variation comes in either single or dual potentiometer packages. An SPI interface specifies resistance levels from 0-256, which we express in hexadecimal 0x00 to 0xFF. We can calculate resolution in ohms by dividing the total resistance by 256.
Therefore, a value of 0x80 (128) corresponds to half of the device’s total resistance– 5kΩ for the 10kΩ device, and so on.
How to Use a Digital Potentiometer
You’ll use these potentiometers in rheostat mode by connecting the chips wiper (PW0) pin to pin PA0 or PB0 (in a single potentiometer package, 0 dropped further in article). We’ll change the internal resistor as needed, increasing resistance between PA and PB as a rheostat. We can also reverse polarity in this mode without affecting operation.
As you’ve probably guessed, these devices can also act as potentiometers in two quick steps:
1. First, connect PA to one voltage level.
2. Connect PB to another voltage level, which may be ground in many applications.
We can express the resistance between PW and PA (RWA) as:
RAB(256-Dn)/256 +RW
We can express the resistance between PW and PB (RWB) as:
(Dn)/256 +RW
In this equation, Rw is the resistance of the wiper and Dn represents the 8-bit value passed to the pot from the digital controller. For further information and definitions relating to these terms, check out the digital potentiometer datasheet, available from Arrow.
Assuming PB is pulled to ground and voltage is on the wiper, PW will be equal to:
RWB / (RWB + RWA) x Vin
Digital Potentiometer with Arduino

Image: Emulate the functionality of an analog pot with a digital potentiometer chip
If you’d like to try out this device, we recommend pairing it with an Arduino. Set up your connections to match the image above, referring to the datasheet for pin numbers.
1. Wire 5V to VDD (8) and PA (5)
2. Connect the ground to PB (7) and VSS (4)
3. Next, connect a resistor in the 100Ω range to PW (6), then to an LED
4. The LED should connect to ground to connect the circuit
5. Arduino pin 10 goes to CS (1) on the MCP41XXX
6. Pin 11 will connect to SI (3)
7. Finally, connect pin 13 to SCK (2)
Once you’ve made these connections, load the LED-Blink sketch onto the Arduino (other Arduino tutorials here). This sketch includes an SPI library for communication with the chip. As programmed, the device will flash the LED by varying voltage over time.
With that process complete, you can then modify the program’s parameters to see how it affects operation. Of course, we can expand this code as needed, allowing you to control analog devices without resorting to PWM control. Since it’s an SPI device, it’s also possible to expand into multiple potentiometers. The MCP42 dual potentiometer format even includes a SO pin for daisy-chaining multiple modules together.

