Remotely controllable resistors

Today some new potentiometers arrived – digital potentiometers in Plastic DIP (PDIP) package. I ordered some MCP41010 and MCP41100’s with a value of 10 kΩ and 100 kΩ respectively.

These potentiometers operate with a 2.7-5.5V supply, consume <1 µA and have a SPI interface to control the wiper position. The maximum wiper current can be 1 mA and its position varies linearly according to the 256 positions (steps) to which it can be set. Well, if you need to know more, all info can be found here. And they’re not expensive; <2 Euro each.

The first thing I tried was controlling one of those potentiometers with a spare Arduino and see if I could dim a LED with it.

Digital potentiometer

An Arduino, an MCP41010, a resistor, LED and some wires were put on a breadboard and I started reading the datasheet to find out how I could control the wiper resistance.

There are 3 commands available to control the DigiPot: one to write a new value (to set the wiper position), a shutdown command and a NOP command. After this command byte follows a data byte. For example, to set the wiper position to 25%, 2 bytes have to be sent: 0x11, 0x40. And for 50% it’s 0x11, 0x80. Let’s write some code now…

The Arduino (1.0) SPI library comes with a Digital potentiometer example, so with some  modifications not worth mentioning I came up with this:

#include <SPI.h>

const int slaveSelectPin = 10;

void setup()
  pinMode (slaveSelectPin, OUTPUT);

void loop()
    for (int level = 0; level <= 255; level++)

    for (int level = 255; level >= 0; level--)

int digitalPotWrite(int value)
  digitalWrite(slaveSelectPin, LOW);
  digitalWrite(slaveSelectPin, HIGH);

This sketch will continuously brighten and dim the LED each 6 seconds – that’s all there is to it!

Some details that can be important to know is that these digipots have a minimum resistance – for example, the 10 kΩ version I used here has a minimum resistance of 52 Ω. Another thing to keep in mind is that the wiper position goes to the mid-scale position upon power-up, so it doesn’t remember the position it had before the last shutdown.

Why did I buy these digital potentiometers? Well, not to SPI-enable the volume knob on our AV receiver, but to fool our room thermostat and make it believe it’s colder than it really is – either by putting a 10 kΩ version in series with the external NTC sensor or totally replacing it by 2 x 100k parallel, which gives me a range of ≈50 kΩ.

But before I get there, I’ll have to find a more suitable digipot – non-volatile, available in a size I can easily handle (DIP) and as much steps as I will need.

To be continued…

Tagged . Bookmark the permalink.

3 Responses to Remotely controllable resistors

  1. Allen says:

    I just got a MCP41100 digipot and set it up. It is suppose to max out at 100kOhm, but when I send 255 to it, it only reads 62kOhm. Any thoughts as to why? Thanks. -Allen

  2. Alain says:

    Good job Robert

Leave a Reply

Your email address will not be published. Required fields are marked *