# Digital Pot Library

**URL:** https://forum.xod.io/t/digital-pot-library/5414
**Category:** XOD Programming Questions
**Created:** [August 26, 2021, 11:33am UTC](https://forum.xod.io/t/digital-pot-library/5414 "2021-08-26T11:33:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![krugdu](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@krugdu](https://forum.xod.io/u/krugdu)
#### Post date: [August 26, 2021, 11:33am UTC](https://forum.xod.io/t/digital-pot-library/5414/1 "2021-08-26T11:33:19Z")

</div>

Has anyone generated a library for connecting a digital pot to an Arduino using XOD? There are two from Adafruit, see below.

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/5/54846dfe6da2938f094c88b38e197c40f907ce1e.jpeg)

I’m trying to control an analog temperature gauge with my Arduino. The sending unit for the gauge is a 10K thermistor. If I use the the digital pot in place of the thermistor I figure I should be able to manipulate the gauge.

Has anyone done something like this? Perhaps there is another way to achieve the same results without the use of a digital pot.

---

<div class="post-metadata">

### Author: ![xodballxod](https://avatars.discourse-cdn.com/v4/letter/x/f475e1/32.png) [@xodballxod](https://forum.xod.io/u/xodballxod)
#### Post date: [August 28, 2021, 4:16pm UTC](https://forum.xod.io/t/digital-pot-library/5414/2 "2021-08-28T16:16:14Z")

</div>

There’s a GitHub library for it, so it’s very doable…

> **[GitHub - adafruit/Adafruit\_DS1841](https://github.com/adafruit/Adafruit_DS1841)**
>
> Contribute to adafruit/Adafruit\_DS1841 development by creating an account on GitHub.

You gotta wrap the arduino library inside XOD.

> [@Usage of i2c devices](https://forum.xod.io/t/usage-of-i2c-devices/5406/3):
>
> In General: I just got multiple different I2C devices on the same BUS… Check out the solution to this recent post. The key is not crash the device communications into each other. There are several ways to do this. The simplest is to make a continuous daisy chain… [https://forum.xod.io/t/mcp4725-odd-behavior-does-not-update-with-number-directly/5393/3?u=xodballxod](https://forum.xod.io/t/mcp4725-odd-behavior-does-not-update-with-number-directly/5393/3) Now, you need a library in XOD… You’ve got to make your own, or maybe one of the XODERS can adapt it for you. You gotta start with th…

Next time I need an I2C library, my plan is to try to copy this one, and just change all the parameters for my device.  
[https://xod.io/libs/wayland/ads1115/](https://xod.io/libs/wayland/ads1115/)

---

<div class="post-metadata">

### Author: ![dawreski](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@dawreski](https://forum.xod.io/u/dawreski)
#### Post date: [August 30, 2021, 4:23pm UTC](https://forum.xod.io/t/digital-pot-library/5414/3 "2021-08-30T16:23:12Z")

</div>

Couldn’t you generate a PWM to control that analog gauges readings ?

---

<div class="post-metadata">

### Author: ![xodballxod](https://avatars.discourse-cdn.com/v4/letter/x/f475e1/32.png) [@xodballxod](https://forum.xod.io/u/xodballxod)
#### Post date: [August 30, 2021, 7:27pm UTC](https://forum.xod.io/t/digital-pot-library/5414/4 "2021-08-30T19:27:48Z")

</div>

In that case, I’ve had a lot of good luck with the MCP4725, it gives a steady 0 to 5 V output… Perfect for controlling the dial, in that way. There’s a library, too. Using PWM will prove the concept, but I’ve not had good luck building filters to steady PWM. The MCP4725 is steady.

---

<div class="post-metadata">

### Author: ![krugdu](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@krugdu](https://forum.xod.io/u/krugdu)
#### Post date: [August 31, 2021, 2:09am UTC](https://forum.xod.io/t/digital-pot-library/5414/5 "2021-08-31T02:09:08Z")

</div>

That sound promising. Are you suggesting using the MCP4725 to control a MOSFET? It’s a 12volt automotive gauge that I want to manipulate. I’ve used a N-channel MOSFET with PWM from the Arduino to control a DC motor. Could I use the MCP4725 digital to analog board to control a MOSFET that regulates 0 to 12 volts to the gauge. I have two gauges I would like to control. It look like I can use two MCP4725’s on the I2C bus. That’s a plus!

---

<div class="post-metadata">

### Author: ![xodballxod](https://avatars.discourse-cdn.com/v4/letter/x/f475e1/32.png) [@xodballxod](https://forum.xod.io/u/xodballxod)
#### Post date: [August 31, 2021, 4:09am UTC](https://forum.xod.io/t/digital-pot-library/5414/6 "2021-08-31T04:09:03Z")

</div>

That sounds like it can work. Though, the MOSFET obviously has to be linear within that region, I guess the 0 to 5 V region. That’s the best I can offer without wrapping the library.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)
#### Post date: [September 30, 2021, 4:09am UTC](https://forum.xod.io/t/digital-pot-library/5414/7 "2021-09-30T04:09:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
