Interfacing X9C103S Digital Potentiometer Module with Arduino

Table of Contents

X9C103S Digital Potentiometer Module Features

The X9C103S 10k digital potentiometer module is a variable resistor whose resistance value can be varied digitally from a microcontroller. It consists of a 3-pin output which can replace a mechanical potentiometer which has 3 pins. This module has 99 resistance components and the final resistor is controlled by a 3-wire interface.

X9C103S Digital Potentiometer Module Pinout

This sensor has 8 wires:

  • VCC: Module power supply – 5V
  • CS: Chip Select. Active LOW
  • INC: Changing resistor command
  • U/D: UP / Down. Adjusting resistor
  • GND: Ground
  • VL: Voltage Low
  • VW: Voltage Wiper is the voltage output of the adjustable wiper contact
  • VH: Voltage High
Note

The 3-pin output can replace a mechanical potentiometer which has 3 pins.

You can see the pinout of this module here.

Required Materials

Hardware Components

Arduino UNO R3 × 1
10K X9C103S Digital Potentiometer Module × 1
male-female-jumper-wire × 1

Software Apps

Arduino IDE

Interfacing X9C103S Digital Potentiometer Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to X9C103S module. Connect wires accordingly.

Step 2: Installing Library

Download the DigiPotX9Cxxx library here. Then go to the Include Library and install the library.

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to Arduino. After that open Serial Monitor.

 /*  
Modified on Nov 16, 2020
Modified by MehranMaleki from Arduino Examples
Home
*/ /* * For this example, connect your X9C103P (or the like) as follows: * 1 - INC - Arduino pin 2 * 2 - U/D - Arduino pin 3 * 3 - VH - 5V * 4 - VSS - GND * 5 - VW - Output: Arduino pin A0 for analogRead * 6 - VL - GND * 7 - CS - Arduino pin 4 * 8 - VCC - 5V */ #include <DigiPotX9Cxxx.h> DigiPot pot(2,3,4); void setup() { Serial.begin(9600); } void loop() { Serial.println("Starting"); for (int i=0; i<100; i++) { pot.increase(1); Serial.println(analogRead(A0)); delay(20); } for (int i=0; i<100; i++) { pot.decrease(1); Serial.println(analogRead(A0)); delay(20); } }

In this code, the Arduino pins 2, 3 and 4 are first connected to the INC, U / D and CS, respectively. Then, first the variable output voltage goes up and then down. The output value which is set by the Arduino is read by pin A0 and displayed in the Serial Plotter.

The output is as follows.

Liked What you see?

Get updates and learn from the best

More To Explore

Comments (4)

  • Steve Reply

    I would like to attach a button (a momentary button or switch) to make the potentiometer increase slowly when the momentary button is clicked, and then decrease slowly when the momentary button is clicked. How can I do that. I know enough electronics to be dangerous. Also, can I connect this shield to an Ardino Nano or smaller?

    May 7, 2021 at 12:25 am
    • Mehran Maleki Reply

      Hi.
      The code provided here is to increase and decrease the resistance of the potentiometer over time, and what you want to do is to have a button to control this increasing and decreasing of the potentiometer. It’s possible and that’s how you can do that: Use one of the digital pins of your microcontroller as the input of the button. Put the increasing and decreasing parts of the code in an if statement and use the state of the button as the condition of that if statement. Then the potentiometer will only change if the button is pressed.
      And about your last question, yes. You can connect this module to an Arduino Nano or any other Arduino board and use the same code.

      May 9, 2021 at 4:46 am
  • Mistirios Reply

    I thing that the module’s pinout picture is wrong.

    July 26, 2021 at 1:30 pm
    • Mehran Maleki Reply

      Hello my friend. Thanks for your attention! It seems that something has gone wrong while uploading the article on the website.
      Now the post is updated, and the pinout picture is replaced with the correct one.

      July 27, 2021 at 5:09 am

Leave a Reply

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