You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.


Digital potentiometer is a module whose function is identical to the one of the potentiometer, only instead of physical rotating part which is used to adjust the resistance, it uses digital communication. Namely, the digital potentiometer’s resistance is adjusted via I2C communication.

• Voltage: 1.8V – 5V
• Potentiometer resistance: 10k
• Wiper resistance: 100ohm
• Dimensions: 22 x 22 mm


Since the digital potentiometer uses I2C communication for all purposes, in the following text we will explain how the I2C works. The I2C protocol uses two lines for sending and receiving data. Those are Serial Clock pin (SCL) which is used by Dasduino to send impulses during given intervals and Serial Data pin (SDA) through which the data is sent between two devices. As the Clock line changes from LOW to HIGH, one bit of information, which will be shaped in a form of an address and command or data is transmitted from Dasduino to the I2C module via SDA line. When these data are sent bit by bit, the called device executes a request and sends data to Dasduino via that same line using the Clock signal, generated on the SCL pin, on the Master device.

The I2C protocol allows each called device to have its unique address because master and slave devices communicate interchangeably over one line. It is possible to have your Dasduino communicate (interchangeably) with multiple devices, or other boards while using only two pins of your microcontroller.

This is how we will control the digital potentiometer using I2C communication. Through the commands we can reduce or increase resistance of the potentiometer, i.e. output current from the module. The resistance can be decreased or increased automatically, during the desired time interval or set constant. We can control the resistance we want depending on the steps.  Our module is based on the MCP4018 IC which has a total of 128 steps of adjusting resistance between resistance values 0 and 10k, which is 78 Ohms per step.



In this case we will show a simple example with the digital potentiometer. We will make a flash that illuminates slowly. The digital resistor consists of:
• SCL – Serial Clock (Signal time generator)
• SDA – Serial Data (Communication line)
• VCC – Module power supply
 GND – Module ground
• A – Potentiometer input (5V, 3.3V)
• W – Wiper, variable part of the potentiometer
• B – Potentiometer output (GND)

We connect the SCL to analog pin 5 of the Dasduino. Dasduino’s analog pin 5 is intended for the SCL connector of the I2C communication, which can be seen HERE. The same goes for the SDA pin which is connected to the analog pin 4. Then, we connect the VCC to 5V and GND to Dasduino’s GND. The connector is connected to 5Vand the connector to GND. For connecting the LED diode to the series we will add a smaller resistor, in this case, a 220 Ohm resistor. To one end, we connect the W connector, and to the other the Anode of the LED diode (mind the polarity while connecting the diode). The shorter part, Cathode is connected to the GND.


For the following code, we will need the Wire Library, in case you do not have it, you can download it HERE.

#include "Wire.h"  //The library necessary for I2C communication
void setup() {
  Wire.begin(); // joining the I2C line
// Wire.begin(Master address, optional)
byte val = 0;
void loop() {
  Wire.beginTransmission(47); // emitting on the device #47 (0101111)
  // we find the device address in the datasheet
  Wire.write(byte(0x00));            // sending instructional byte
  Wire.write(val);             // sending the potentiometer value (byte)
  Wire.endTransmission();     // end of emission
  val++;        // increment value
  if (val == 128) { // if it reaches the 128th step (maximum)
    val = 0;    // starts from the beginning