Digital Potentiometer Arduino Interface

Variable Resistor or Potentiometer gives different range of Resistance value in circuit and used in many applications like volume control for Audio circuit, Television, Oscillators, Home Electrical appliance etc..,

This Article describes what is digital potentiometer? and How to interface with Arduino board.

What is digital Potentiometer?

A digital potentiometer comes in a integrated circuit (IC) package and it mimics the physical mechanical variable resistor or potentiometer with the help of control signals.

Digital Potentiometer MCP41xx

The MCP41XX is a single-channel digital potentiometer device and is offered in an 8-pin PDIP or SOIC package by microchip company, the MCP41XX device is 256 – position, digital potentiometers available in 10 kΩ, 50 kΩ and 100 kΩ resistance versions.  There is MCP42XXX available to provide two channel digital potentiometers. The wiper position of the MCP41XXX/42XXX varies linearly and is controlled via an industry-standard SPI interface. [find more on datasheet].

Typical digital potentiometer have High resistance value pin, Low resistance value pin and Wiper for variable terminal and this wiper output is controlled by the digital control pins. Here function diagram of MCP41xx is given with comparison, PB0 represents High, PA0 represents Low and PW0 represents wiper terminals. By varying the control signals we can get different resistance value at wiper (PW0) terminal.

Arduino Interfacing to digipot MCP41xx

In this interfacing circuit an LED is taken as target device and bias to that LED is given followed by digital potentiometer and control signals are driven by the Arduino controller. This circuit gives different intensity level LED light output by varying the Resistance value inside the digital potentiometer MCP41xx.

Arduino Code

 

#include <SPI.h>

byte address = 0x00;
int CS= 10;

void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
}

void loop()
{
for (int i = 0; i <= 128; i++)
{
digitalPotWrite(i);
delay(10);
}
delay(500);
for (int i = 128; i >= 0; i--)
{
digitalPotWrite(i);
delay(10);
}
}

int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}

Add a Comment

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