MCP41010 Digital Potentiometer Arduino User Manual

Providing Analog Output Control

MCP41010 Digital Pot

The MCP41010 is a digital potentiometer that is controlled using a SPI Interface.    It is fully adjustable using 256 steps from approximately zero to 10K ohms (or about 39 ohms per step)

 

 

 

 

MCP41010 Pin Outs

The device pin outs are show below.

MCP41010 Digital Potentiometer PinoutsPin 1 – CS – Chip Select.   When low,  the chip will will receive commands from the Serial Input at pin 3.

Pin 2 – SCK – Serial Clock.   Clock input from the micro-controller that synchronizes serial communications.

Pin 3 – SI – Serial Input.   Receives commands from the micro-controller when CS at pin 1 is low.

Pin 4 – Vss – Negative Supply or Ground.

Pin 5 – PA0 – Potentiometer Terminal A.

Pin 6 PWO – Potentiometer Wiper

Pin 7 – PAB – Potentiometer Terminal B.

Pin 8 – Vdd – Positive Supply or Ground.

The Potentiometer Output

The position of the wiper on the potentiometer is control via the SPI interface.   With a fixed voltage applied to terminals 5 and 7,  the SPI commands that change wiper position will change the voltage at the Pin 7.

MCP41010 Digital Potentiometer Wiper

 MCP41010 Arduino Tutorial

This tutorial connects the MCP41010 to the Arduino via the Arduino’s SPI Interface.    Potentiometer terminals B and A are connected to the Arduino 5 volt Supply and Ground.  The wiper is connected the Analog Pin 1.

The sketch loaded into the Arduino then selects the MCP4010 and cycles through all 256 wiper positions.   The voltage at the analog pin is then read and displayed on the serial monitor.

Connections to the Arduino

Connect your Arduino to the MCP41010 potentiometer as shown.  Click on the image to make it bigger if necessary.

MCP41010 Arduino ConnectionsArduino Sketch

The code is pretty basic.  Just cut and paste the code shown below.

/*MCP41010 Tutorial*/

#include <SPI.h>  
const int CS = 10;
int PotWiperVoltage = 1;
int RawVoltage = 0;
float Voltage = 0;
 
void setup() {
  pinMode (CS, OUTPUT);   
  Serial.begin(9600);
  SPI.begin();    
}
 
void loop() {
  // move the potentiometer in one direction
  for (int level = 0; level < 255; level++) 
  {
    MCP41010Write(level);
    delay(100);
    RawVoltage = analogRead(PotWiperVoltage);
    Voltage = (RawVoltage * 5.0 )/ 1024.0;
    Serial.print("Level = " );                      
    Serial.print(level);      
    Serial.print("\t Voltage = ");
    Serial.println(Voltage,3);  
  }
  delay(2000);  // wait a couple seconds
  // Now mover potentiometer in other directions
  
  for (int level = 255; level > 0; level--) 
  {
    MCP41010Write(level);
    delay(100);
    RawVoltage = analogRead(PotWiperVoltage);
    Voltage = (RawVoltage * 5.0 )/ 1024.0;
    Serial.print("Level = " );                      
    Serial.print(level);      
    Serial.print("\t Voltage = ");
    Serial.println(Voltage,3); 
  }
   delay(2000);
}
 
void MCP41010Write(byte value) 
{
  // Note that the integer vale passed to this subroutine
  // is cast to a byte
  
  digitalWrite(CS,LOW);
  SPI.transfer(B00010001); // This tells the chip to set the pot
  SPI.transfer(value);     // This tells it the pot position
  digitalWrite(CS,HIGH); 
}

Sketch Results

In my sample, the voltage measurement at Analog Pin one changed approximately 20 mV for every level change in the wiper.   You results will very and will depend on the voltage applied to PA0 and PB0 and the differences in your particular chip.

 Related Resources

MCP41010 Datasheet

3 Comments

  1. capnfatz@gmail.comAuthor June 2, 2017
  2. Bob A June 2, 2017
  3. i-dnz March 3, 2017

Add a Comment

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