Post Go back to editing

Controlling digital potentiometer (AD5142) by Arduino UNO

Hi, I am trying to control digital potentiometer (AD5142) by Arduino UNO.

Here is the pin configuration of AD5142.

I connect SCLK pin to 13 pin of Arduino (serial clock pin), SDI pin to 11 pin of Arduino (MOSI pin) and SDO pin to 12 pin of Arduino (MISO pin).

SYNC pin was connected to digital output pin of Arduino.

And according to the data sheet of AD5142, I connected the RESET pin to V(LOGIC) pin because I don't want to use reset.

V(DD), A1 and A2 pin to 5V and V(SS) to ground.

And I used the Arduino code below,


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

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

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

void loop() {
int channel1 = 0;
double voltage1 = 2;
double level1 = voltage1 * 51;
digitalPotWrite(channel1, level1);

int channel2 = 1;
double voltage2 = 2;
double level2 = voltage2 * 51;
digitalPotWrite(channel2, level2);

void digitalPotWrite(int address, double 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:


However, I cannot control the resistance of AD5142.

Can you help me?