There are a couple of old posts with example code and wiring schematics for Pi and MCP4130 digital pots. I've tried using these code examples and believe I have wired it up correctly but my LED does nothing. I've verified the LED works. I verified the GPIO Pins are changing to OUT using GPIO readall while the script is running. I've verified through various tutorials and posts that SPI is active and working properly. I'm new with Pi so I'm sure I'm missing something. If someone could take a look at my wiring and the code from a past post and let me know if you see anything or if you have your own example code I would appreciate any help.
enter image description here

Link to the data sheet:


And the code from previous post:

import sys
import time
import RPi.GPIO as GPIO
import spidev


def sleep(a = .5):

def wait_a_key():
    print "waiting..."



GPIO.output(SPI_CLK_PIN, False)
GPIO.output(SPI_SDISDO_PIN, False)
GPIO.output(SPI_CS_PIN, False)

print "Setup"
GPIO.output(SPI_CS_PIN, True)
GPIO.output(SPI_CLK_PIN, False)
GPIO.output(SPI_CS_PIN, False)

def set_value(b):
    b = "0000" "00" "{0:010b}".format(b)

GPIO.output(SPI_CS_PIN, False)
for x in b:
    GPIO.output(SPI_SDISDO_PIN, int(x))
    GPIO.output(SPI_CLK_PIN, True)
    GPIO.output(SPI_CLK_PIN, False)


GPIO.output(SPI_CS_PIN, True)

    for i in range(0, 100, 10):
        print 'set_value:' + str(i)

    print "GPIO Cleanup"

This code was used with an MCP4131 digital pot so would that be an issue using this with a 41010? I'm new enough at all this so I could easily be missing something. And another NOOB question, on the Pi 3 pinout, CE0 is BCM Pin 8, MOSI is BCM Pin 10, and the clock pin is BCM 11 which is how I have it wired but I have seen wiring to other available GPIO pins and just defined those pins as CS, CLK, and SDI/SDO. Is either way correct or am I doing it incorrectly? I've tried both ways with the same result but I'm curious anyway.

Thanks for any help. I've enjoyed learning from those on this site.

  • 2
    Please flag to reject this migration. The problem has nothing to do with RPi.
    – cde
    Commented May 14, 2017 at 22:56
  • Why not use hardware SPI rather than that rather strange bit bang approach? Do you need to use special GPIO? A clear photo would be more useful than a schematic. There is no way to tell if you have implemented the schematic properly without a clear photo. You should also link to the device specs in your question.
    – joan
    Commented May 15, 2017 at 7:58
  • Here is the ultimate goal: I want to vary the resistance of the input voltage of a gas cell (CO, CO2, O2) for zero and span adjustments. The Qt GUI has buttons that I want to be able to push for increased and decreased resistance in some increment that I set. I'm open to any suggestions that you may have. I'm new at this and there likely is a better way. I didn't burn out the Digital Pots, they are still working. I found a bit of code last night and it is functioning as wired. The LED starts full on then dims little by little. I can post that code if you wish. Thanks for your time.
    – kjohns
    Commented May 15, 2017 at 14:33
  • @kjohns whats the gas cell part and data sheet link?
    – cde
    Commented May 17, 2017 at 3:01

1 Answer 1


Measure the resistance at PW0 and PA0. Is it changing when you tell it to change?

Likely not. The MCP41xxx has a maximum wiper current of 1mA. More than that and you likely burn out the wiper. Digital pots are not meant to be used for actual loads, they are meant to be used for reference applications (like controlling a voltage regulator's Adjust pin).

I figure you damaged the part.

  • Ok, thanks for the reply. I guess I'm not sure that I understand. This setup has worked for others on this site and elsewhere. So a digital pot can't dim and brighten an LED? Is it because I wired something wrong or the wrong digital pot?
    – kjohns
    Commented May 14, 2017 at 17:13
  • Only if the current through the wiper is less than 1 mA. It's a physical limit of the construction of the pot What others, link please?
    – cde
    Commented May 14, 2017 at 17:30
  • I've used this:
    – kjohns
    Commented May 14, 2017 at 17:43
  • Sorry, this site takaitra.com/posts/503
    – kjohns
    Commented May 14, 2017 at 17:43
  • 1
    Not by much the mcp41xx has 2.5 mA max on the wipers. Most digital pots are similar. If you need led brightness control, look for PWM solutions. A digital pot is not the solution. There are plenty of i2c controllable led controllers.
    – cde
    Commented May 14, 2017 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.