Interfacing X9C104 100K Digital Potentiometer Module with Arduino

Table of Contents

X9C104 100K Digital Potentiometer Module Features

The X9C104 digital potentiometer module is a variable resistor whose resistance value can be set digitally by a microcontroller. It consists of  3 output pins (RH، RW و RL) which can replace a mechanical potentiometer which has 3 pins. This module has 99 resistance components and its resistor is controlled by a 3-wire interface.

X9C104 100K Digital Potentiometer Module Pinout

This sensor has 10 pins:

5 pins on the left side:

  • VCC: Module power supply – 5V
  • GND: Ground
  • INC: Changing resistor command
  • U/D: UP / Down. Adjusting resistor
  • CS: Chip Select. Active LOW

5 pins on the right side:

  • VCC: Module power supply – 5V
  • RH: Resistor High
  • RW: Regulated Resistor
  • RL: Resistor Low
  • GND: Ground
Note

The 3 RH, RW and RL pins can replace a mechanical potentiometer which has 3 pins

You can see the pinout of this module here.

Required Material

Hardware component

Arduino UNO R3R3 × 1
X9C104 100K Digital Potentiometer Module × 1
Male to Female Jumper wire × 1

Software Apps

Arduino IDE

Interfacing X9C104 100K Digital Potentiometer Module with Arduino

Step 1: Circuit

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

Step 2: Installing Library

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

Note

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 the Serial Plotter.

  /*  
Modified on Dec 12, 2020
Modified by MehranMaleki from Arduino Examples
Home
*/ /* * For this example, connect your X9C104 (or the like) as follows: * 1 - INC - Arduino pin 2 * 2 - U/D - Arduino pin 3 * 3 - RH - 5V * 4 - VSS - GND * 5 - RW - Output: Arduino pin A0 for analogRead * 6 - RL - 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"); float voltage; for (int i=0; i<100; i++) { pot.increase(1); voltage = 5.0 * analogRead(A0) / 1024; Serial.println(voltage); delay(20); } for (int i=0; i<100; i++) { pot.decrease(1); voltage = 5.0 * analogRead(A0) / 1024; Serial.println(voltage); delay(20); } }

In this code, the Arduino pins 2, 3 and 4 are connected to the INC, U/D and CS, respectively. Then, at first the variable output voltage goes up and then goes down. The output value is read by Arduino 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 (6)

  • Etienne Reply

    Thanks for this very good tutorial.
    Worked perfectly.

    May 14, 2021 at 7:16 pm
    • Mehran Maleki Reply

      You’re quite welcome. We always try to do our best.

      May 17, 2021 at 4:51 am
  • dave Reply

    Thanks for the nice info.

    Your pinout says “VCC: Module power supply – 5V”.
    This should be Vcc is +ve ?

    June 8, 2021 at 11:21 am
    • Mehran Maleki Reply

      Hi,
      There can actually be different symbols representing the positive end of the power supply. And among them VCC and +ve are the most popular ones. So, they can be used alternatively.

      June 9, 2021 at 7:11 am
  • Michael Reply

    Please help me if you can. I need to use the x9c to regulate either power on, or power completely off. I understood the RH HIGH is complete resistance (no power) and RH LOW is very little resistance (nearly full power). Did I get that right?

    June 24, 2022 at 5:24 am
    • Mehran Maleki Reply

      Hi. You’re absolutely correct.

      July 10, 2022 at 11:31 am

Leave a Reply

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