跳转到主要内容

ADC+DAC组合

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

ADC+DAC组合

依赖项

此驱动程序依赖于

请确保所有依赖项都在CircuitPython文件系统中可用。这可以通过下载 Adafruit库和驱动程序捆绑包 来轻松实现。

从PyPI安装

在支持GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI 本地安装此驱动程序。为当前用户安装

pip3 install adafruit-circuitpython-pcf8591

要系统范围安装(在某些情况下可能需要)

sudo pip3 install adafruit-circuitpython-pcf8591

在您当前项目的虚拟环境中安装

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-pcf8591

使用示例

import time
import board

import adafruit_pcf8591.pcf8591 as PCF
from adafruit_pcf8591.analog_in import AnalogIn
from adafruit_pcf8591.analog_out import AnalogOut

############# AnalogOut & AnalogIn Example ##########################
#
# This example shows how to use the included AnalogIn and AnalogOut
# classes to set the internal DAC to output a voltage and then measure
# it with the first ADC channel.
#
# Wiring:
# Connect the DAC output to the first ADC channel, in addition to the
# normal power and I2C connections
#
#####################################################################
i2c = board.I2C()
pcf = PCF.PCF8591(i2c)

pcf_in_0 = AnalogIn(pcf, PCF.A0)
pcf_out = AnalogOut(pcf, PCF.OUT)

while True:

    print("Setting out to ", 65535)
    pcf_out.value = 65535
    raw_value = pcf_in_0.value
    scaled_value = (raw_value / 65535) * pcf_in_0.reference_voltage

    print("Pin 0: %0.2fV" % (scaled_value))
    print("")
    time.sleep(1)

文档

此库的API文档可以在 Read the Docs 上找到。

有关构建库文档的信息,请参阅 本指南

贡献

欢迎贡献!在向本项目做出贡献之前,请阅读我们的 行为准则,以帮助本项目保持友好。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

adafruit-circuitpython-pcf8591-1.0.18.tar.gz (28.9 kB 查看哈希值)

上传时间

构建分布

adafruit_circuitpython_pcf8591-1.0.18-py3-none-any.whl (8.9 kB 查看哈希值)

上传时间 Python 3