Skip to main content

Python driver for MCP2221/A

Project description

Python driver for MCP2221/A

Build PyPI

Examples

Read GP0

from MCP2221 import MCP2221

mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(0, MCP2221.TYPE.INPUT)
print(mcp2221.ReadGP(0))

Write GP0

from MCP2221 import MCP2221

mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(0, MCP2221.TYPE.OUTPUT)
print(mcp2221.WriteGP(0, 1))

Read ADC on GP1

from MCP2221 import MCP2221

mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(1, MCP2221.TYPE.ADC)
mcp2221.SetADCVoltageReference(MCP2221.VRM.VDD)
print(mcp2221.ReadADC(1))

Write DAC on GP2

from MCP2221 import MCP2221

mcp2221 = MCP2221.MCP2221()
mcp2221.InitGP(2, MCP2221.TYPE.DAC)
mcp2221.SetDACVoltageReference(MCP2221.VRM.REF_2_048V)
mcp2221.WriteDAC(12)

Tests

pip install pytest pytest-cov
pytest tests/ --doctest-modules --cov=MCP2221

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp2221-1.1.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

mcp2221-1.1.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page