/ README.rst
README.rst
  1  Introduction
  2  ============
  3  
  4  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ds3502/badge/?version=latest
  5      :target: https://circuitpython.readthedocs.io/projects/ds3502/en/latest/
  6      :alt: Documentation Status
  7  
  8  .. image:: https://img.shields.io/discord/327254708534116352.svg
  9      :target: https://adafru.it/discord
 10      :alt: Discord
 11  
 12  .. image:: https://github.com/adafruit/Adafruit_CircuitPython_DS3502/workflows/Build%20CI/badge.svg
 13      :target: https://github.com/adafruit/Adafruit_CircuitPython_DS3502/actions/
 14      :alt: Build Status
 15  
 16  CircuitPython library for the Maxim DS3502 I2C Potentionmeter
 17  
 18  
 19  Dependencies
 20  =============
 21  This driver depends on:
 22  
 23  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 24  * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
 25  * `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
 26  
 27  Please ensure all dependencies are available on the CircuitPython filesystem.
 28  This is easily achieved by downloading
 29  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 30  
 31  Installing from PyPI
 32  --------------------
 33  
 34  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 35  PyPI <https://pypi.org/project/adafruit-circuitpython-ds3502/>`_. To install for current user:
 36  
 37  .. code-block:: shell
 38  
 39      pip3 install adafruit-circuitpython-ds3502
 40  
 41  To install system-wide (this may be required in some cases):
 42  
 43  .. code-block:: shell
 44  
 45      sudo pip3 install adafruit-circuitpython-ds3502
 46  
 47  To install in a virtual environment in your current project:
 48  
 49  .. code-block:: shell
 50  
 51      mkdir project-name && cd project-name
 52      python3 -m venv .env
 53      source .env/bin/activate
 54      pip3 install adafruit-circuitpython-ds3502
 55  
 56  Usage Example
 57  =============
 58  
 59  .. code-block:: python
 60  
 61      from time import sleep
 62      import board
 63      import adafruit_ds3502
 64      from analogio import AnalogIn
 65  
 66      ####### NOTE ################
 67      # this example will not work with Blinka/rasberry Pi due to the lack of analog pins.
 68      # Blinka and Raspberry Pi users should run the "ds3502_blinka_simpletest.py" example
 69  
 70      i2c = board.I2C()
 71      ds3502 = adafruit_ds3502.DS3502(i2c)
 72      wiper_output = AnalogIn(board.A0)
 73  
 74      while True:
 75  
 76          ds3502.wiper = 127
 77          print("Wiper set to %d"%ds3502.wiper)
 78          voltage = wiper_output.value
 79          voltage *= 3.3
 80          voltage /= 65535
 81          print("Wiper voltage: %.2f"%voltage)
 82          print("")
 83          sleep(1.0)
 84          
 85          ds3502.wiper = 0
 86          print("Wiper set to %d"%ds3502.wiper)
 87          voltage = wiper_output.value
 88          voltage *= 3.3
 89          voltage /= 65535
 90          print("Wiper voltage: %.2f"%voltage)
 91          print("")
 92          sleep(1.0)
 93  
 94          ds3502.wiper = 63
 95          print("Wiper set to %d"%ds3502.wiper)
 96          voltage = wiper_output.value
 97          voltage *= 3.3
 98          voltage /= 65535
 99          print("Wiper voltage: %.2f"%voltage)
100          print("")
101          sleep(1.0)
102  
103  
104  Contributing
105  ============
106  
107  Contributions are welcome! Please read our `Code of Conduct
108  <https://github.com/adafruit/Adafruit_CircuitPython_DS3502/blob/master/CODE_OF_CONDUCT.md>`_
109  before contributing to help this project stay welcoming.
110  
111  Documentation
112  =============
113  
114  For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.