MCP41010 SPI Digital Potentiometer

Replace a hardware trim pot with a 256-step digital potentiometer controlled over SPI — set the wiper position from code and read it back the same way every time.

Difficulty: Breadboard. Estimated build time: about 40 minutes. Estimated parts cost: about US$5.20. 5-line bill of materials. Compare supplier offers when available. An MCU-driven digital potentiometer: an analog circuit element whose wiper position is set by a single SPI command from your microcontroller.

Wire SPI

Pin out: 1=CS (active low), 2=SCK, 3=SDI (MOSI), 4=Vss/GND, 5=Wiper, 6=P0B, 7=P0A, 8=Vdd. Tie Vdd to 3.3 V (or 5 V), Vss to GND, and connect CS, SCK, and SDI to three GPIOs on your MCU — if you're using an Arduino UNO that's pins 10, 13, 11 respectively. The chip is SPI mode 0,0 — idle low, sample on rising edge — and runs up to 10 MHz.

Wire the analog load

We're using the chip as a rheostat: tie P0A (pin 7) to +5 V, leave P0B (pin 6) unconnected (or also tie it to one of the rails depending on the divider topology you want). The wiper W (pin 5) feeds a 330 Ohm resistor and then an LED to GND. As you raise the wiper position from 0 to 255, the resistance between P0A and W climbs from ~125 Ohm (zero-scale plus wiper resistance) up to about 10 kOhm at full scale — so the LED is bright at position 0 and barely glowing at 255.

Sweep in code

On the MCU: drop CS low, send the command byte 0x11 (write data, potentiometer 0), then send the position byte (0..255), then raise CS. That's one wiper update. Put it in a for-loop that walks 0..255 with a small delay and you'll see the LED fade smoothly through 256 distinct brightness levels. Now swap the LED for an audio coupling cap into an LM386 amp — you have a software volume knob. The same write pattern works on any SPI digital pot in this family (MCP41/42xx).