Problem with Arduino Tutorial "Controlling a Digital Potentiometer Using SPI"


I am pretty new to Arduino (and electronics in general). I have completed several of the tutorials here without a problem.

But when I try the tutorial "Controlling a Digital Potentiometer Using SPI" ( I just cannot get it to work.

I have checked and double checked the connections on my breadboard. I am using a AD5206 chip from Digikey ( and a Boarduino (

I have no idea what the problem is or where to start with the troubleshooting (other than checking and re-checking the connections which I have done several times).

Can anyone give me some advice?


Does the LED marked D3 glow when the sample sketch is running? The D13 pin it's connected to doubles as the SPI clock pin so you should see at least a faint glow when data is being sent to the AD5206.

Hey thanks for the quick reply.

The pin 13 LED only lights up when the sketch is being uploaded to the Arduino. At the point when the Arduino should be communicating with the AD5206 the pin 13 LED doesn’t light up at all.

I am wondering whether the sketch provided with the tutorial actually sets things up completely?

Again, any help of direction is much appreciated. I pasted the sketch below for ease of reference.

Thanks, Malik

  Digital Pot Control
  This example controls an Analog Devices AD5206 digital potentiometer.
  The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
  A - connect this to voltage
  W - this is the pot's wiper, which changes when you set it
  B - connect this to ground.
 The AD5206 is SPI-compatible,and to command it, you send two bytes, 
 one with the channel number (0 - 5) and one with the resistance value for the
 channel (0 - 255).  
 The circuit:
  * All A pins  of AD5206 connected to +5V
  * All B pins of AD5206 connected to ground
  * An LED and a 220-ohm resisor in series connected from each W pin to ground
  * CS - to digital pin 10  (SS pin)
  * SDI - to digital pin 11 (MOSI pin)
  * CLK - to digital pin 13 (SCK pin)
 created 10 Aug 2010 
 by Tom Igoe
 Thanks to Heather Dewey-Hagborg for the original tutorial, 2005

// inslude the SPI library:
#include <SPI.h>

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  // initialize SPI:

void loop() {
  // go through the six channels of the digital pot:
  for (int channel = 0; channel < 6; channel++) { 
    // change the resistance on this channel from min to max:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, level);
    // wait a second at the top:
    // change the resistance on this channel from max to min:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, 255 - level);


int digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  //  send in the address and value via SPI:
  // take the SS pin high to de-select the chip:

The code looks fine to me. I have to suspect a hardware error. Check the voltages on the pins to see if they match what you expect.

Sounds like a great idea. I am waiting for a multimeter to arrive in the mail, so it will probably take a few days until I can do that. Thanks, Malik

Problem solved! :grin: Thanks for the help.

The multimeter arrived today, and I checked the voltages like you suggested. It turns out that the problem was that I didn't realize that power columns on the new breadboard that I got are segmented.

So, instead of everything being connected on the two outside columns down the full length of the breadboard, the outside columns are broken into two separate sections on each side. Once I bridged that separation everything that was suppose to get current did, and it worked like a charm.

I have a follow on question: This tutorial exercise used each of the 6 digital potentiometers in a sequence (one after the other). Is it possible to use them all simultaneously (or at least like something that would appear simultaneous to the human ear)?


All the best, Malik

Yesif you just send the data one after the other with no delay then it will sound like they are all changing at the same time.

This may be useful to other members, I was trying to post under the AD8402 thread but that is now “read” only.

This is the right code to interface the AD8402, the code that is posted in the older forum is not complete (SPI.begin(); is missing…)

#include <SPI.h>

const int slaveSelectPin = 10;
int value=0;

void setup(){
  pinMode(slaveSelectPin, OUTPUT);
  digitalPotWrite(0,0); // remember to initialize
  digitalPotWrite(1,0); // remember to initialize

void loop(){

for (byte channel = 0; channel < 2; channel++){
  for (byte level = 0; level < 255; level++){
   digitalPotWrite(channel, level);
   Serial.print("  ");

void digitalPotWrite(byte address, byte value){
  digitalWrite(slaveSelectPin, LOW);
  digitalWrite(slaveSelectPin, HIGH);

I am connecting A1 and A2 to GND, B1 and B2 to VDD, and have two LEDs connected to the wipers W1 and W2 and GND ( I am using 220 ohms resistors to limit the current in the LEDs).

When using the AD8402 remember to bring RD_ and SHTDN_ to VDD. I am using a 2.2k resistor.
Hopefully this will help somebody.

malikilam: The multimeter arrived today, and I checked the voltages like you suggested. It turns out that the problem was that I didn't realise that power columns on the new breadboard that I got are segmented.

It has happened before, and it will happen again.

There are two versions of the "MB102" breadboard, one with the power rails divided in the middle, and one with them continuous. The red and blue lines printed on them denote which is which. The divided ones are a nuisance, as there is rarely a reason why you would not want the power rails to be common.